-
Notifications
You must be signed in to change notification settings - Fork 5
/
renaming_and_combining.py
executable file
·45 lines (28 loc) · 1.48 KB
/
renaming_and_combining.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
reviews = pd.read_csv("../input/wine-reviews/winemag-data-130k-v2.csv", index_col=0)
gaming_products = pd.read_csv("../input/things-on-reddit/top-things/top-things/reddits/g/gaming.csv")
gaming_products['subreddit'] = "r/gaming"
movie_products = pd.read_csv("../input/things-on-reddit/top-things/top-things/reddits/m/movies.csv")
movie_products['subreddit'] = "r/movies"
powerlifting_meets = pd.read_csv("../input/powerlifting-database/meets.csv")
powerlifting_competitors = pd.read_csv("../input/powerlifting-database/openpowerlifting.csv")
def check_q1(ans):
expected = reviews.rename(columns={'region_1': 'region', 'region_2': 'locale'})
return ans.head().equals(expected.head())
def answer_q1():
print("""reviews.rename(columns={'region_1': 'region', 'region_2': 'locale'})""")
def check_q2(ans):
expected = reviews.rename_axis("wines", axis="rows")
return ans.head().equals(expected.head())
def answer_q2():
print("""reviews.rename_axis("wines", axis="rows")""")
def check_q3(ans):
expected = pd.concat([gaming_products, movie_products])
return ans.equals(expected)
def answer_q3():
print("""pd.concat([gaming_products, movie_products])""")
def check_q4(ans):
expected = powerlifting_meets.set_index("MeetID").join(powerlifting_competitors.set_index("MeetID"))
return ans.head().equals(expected.head())
def answer_q4():
print("""powerlifting_meets.set_index("MeetID").join(powerlifting_competitors.set_index("MeetID"))""")