Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define count_entries() | |
def count_entries(df, col_name): | |
"""Return a dictionary with counts of | |
occurrences as value for each key.""" | |
# Initialize an empty dictionary: langs_count | |
langs_count = {} | |
# Extract column from DataFrame: col | |
col = df[col_name] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import pandas | |
import pandas as pd | |
# Import Twitter data as DataFrame: df | |
df = pd.read_csv('tweets.csv') | |
# Initialize an empty dictionary: langs_count | |
langs_count = {} | |
# Extract column from DataFrame: col |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define shout_all with parameters word1 and word2 | |
def shout_all(word1, word2): | |
"""Return a tuple of strings""" | |
# Concatenate word1 with '!!!': shout1 | |
shout1 = word1 + '!!!' | |
# Concatenate word2 with '!!!': shout2 | |
shout2 = word2 + '!!!' | |
# Construct a tuple with shout1 and shout2: shout_words |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unpack nums into num1, num2, and num3 | |
num1, num2, num3 = nums | |
# Construct even_nums | |
even_nums = (2, num2, num3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define shout with parameters word1 and word2 | |
def shout(word1, word2): | |
"""Concatenate strings with three exclamation marks""" | |
# Concatenate word1 with '!!!': shout1 | |
shout1 = word1 + '!!!' | |
# Concatenate word2 with '!!!': shout2 | |
shout2 = word2 + '!!!' | |
# Concatenate shout1 with shout2: new_shout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define shout with the parameter, word | |
def shout(word): | |
"""Return a string with three exclamation marks""" | |
# Concatenate the strings: shout_word | |
shout_word = word + '!!!' | |
# Replace print with return | |
return shout_word | |
# Pass 'congratulations' to shout: yell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define shout with the parameter, word | |
def shout(word): | |
"""Print a string with three exclamation marks""" | |
# Concatenate the strings: shout_word | |
shout_word = word + '!!!' | |
# Print shout_word | |
print(shout_word) | |
# Call shout with the string 'congratulations' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the function shout | |
def shout(): | |
"""Print a string with three exclamation marks""" | |
# Concatenate the strings: shout_word | |
shout_word = 'congratulations' + '!!!' | |
# Print shout_word | |
print(shout_word) | |
# Call shout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import cars data | |
import pandas as pd | |
cars = pd.read_csv('cars.csv', index_col = 0) | |
# Use .apply(str.upper) | |
cars["COUNTRY"] = cars["country"].apply(str.upper) |
NewerOlder