This file contains 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
# input | |
import pandas as pd | |
import numpy as np | |
ts = pd.Series(np.arange(20), pd.date_range('2001-01-01', periods=20, freq='2d'), name="values") | |
ts |
This file contains 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
# 1. Parse the following strings to datetime. | |
s1 = "2010 Jan 1" | |
s2 = '31-1-2000' | |
s3 = 'October10, 1996, 10:40pm' | |
# 2. How many days has it been between the end of first world war to the beginning of second world war? | |
"11 November 1918" to "1 september 1939" |
This file contains 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
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/economics.csv") | |
df.head() |
This file contains 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 as pd | |
import numpy as np | |
df = pd.read_csv('Datasets\Titanic.csv').sample(50, random_state=100) | |
n_missing = np.random.randint(4, 15, 1) | |
for i in range(n_missing): | |
row = np.random.randint(1, df.shape[0]) | |
df.at[row, "Age"] = pd.NA |
This file contains 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
# Solution | |
import pandas as pd | |
import numpy as np | |
df1 = pd.read_csv("Datasets/table1.csv") | |
df2 = pd.read_csv("Datasets/table2.csv") |
This file contains 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
# Input | |
import numpy as np | |
np.random.seed(100) | |
arr = pd.Series(np.random.normal(10, 3, (100))) | |
arr.head() |
This file contains 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 as pd | |
df = pd.read_csv('Datasets/Tips100.csv') | |
df.head() |
This file contains 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
# 1 | |
index = [1,2,3,4,5] | |
col1 = list('abcde') | |
col2 = list('pqrst') | |
# 2 | |
# column names: 'name' and 'age' | |
lst = [['Bunny', 25], ['Sunny', 30], | |
['Funny', 26], ['Hunny', 22]] |
This file contains 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
TRAIN_DATA = [("Pizza is a common fast food.", {"entities": [(0, 5, "FOOD")]}), | |
("We ate dosa yesterday.", {"entities": [(7, 11, "FOOD")]}), | |
("Pasta is an italian recipe", {"entities": [(0, 5, "FOOD")]}), | |
("China's noodles are very famous", {"entities": [(8,15, "FOOD")]}), | |
("Shrimps are famous in China too", {"entities": [(0,7, "FOOD")]}), | |
("Lasagna is another classic of Italy", {"entities": [(0,7, "FOOD")]}), | |
("Unagi is a famous seafood of Japan", {"entities": [(0,5, "FOOD")]}), | |
("Tempura , Soba are other famous dishes of Japan", {"entities": [(0,7, "FOOD")]}), | |
("Udon is a healthy type of noodles", {"entities": [(0,4, "ORG")]}), | |
("Chocolate soufflé is extremely famous french cuisine", {"entities": [(0,17, "FOOD")]}), |
This file contains 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
TRAIN_DATA =[ ("Pizza is a common fast food.", {"entities": [(0, 5, "FOOD")]}), | |
("Pasta is an italian recipe", {"entities": [(0, 5, "FOOD")]}), | |
("China's noodles are very famous", {"entities": [(8,14, "FOOD")]}), | |
("Shrimps are famous in China too", {"entities": [(0,7, "FOOD")]}), | |
("Lasagna is another classic of Italy", {"entities": [(0,7, "FOOD")]}), | |
("Sushi is extemely famous and expensive Japanese dish", {"entities": [(0,5, "FOOD")]}), | |
("Unagi is a famous seafood of Japan", {"entities": [(0,5, "FOOD")]}), | |
("Tempura , Soba are other famous dishes of Japan", {"entities": [(0,7, "FOOD")]}), | |
("Udon is a healthy type of noodles", {"entities": [(0,4, "ORG")]}), | |
("Chocolate soufflé is extremely famous french cuisine", {"entities": [(0,17, "FOOD")]}), |