Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shcool_id year students
- 100001 1 80
- 100001 2 98
- 100002 1 71
- shcool_id name
- 100001 SCHOOL_A
- 100002 SCHOOL_B
- 100003 SCHOOL_C
- dict = {}
- for i in range(escolas.shape[0]):
- dict[escolas.iloc[i,0]] = escolas.iloc[i,1]
- escolas["scholl_id"] = escolas["scholl_id"].replace(dict)
- df1['shcool_id'].map(df2.set_index('shcool_id')['name'])
- 0 SCHOOL_A
- 1 SCHOOL_A
- 2 SCHOOL_B
- df1['shcool_id']=df1['shcool_id'].map(df2.set_index('shcool_id')['name'])
- print(df1)
- shcool_id year students
- 0 SCHOOL_A 1 80
- 1 SCHOOL_A 2 98
- 2 SCHOOL_B 1 71
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement