create new column using dictionary padnas
U
111
112
112
d = {112: 'a', 111: 'b'}
df['B'] = df['A'].map(d)
df
Out[248]:
A B
0 111 a
1 112 b
create new column using dictionary padnas
U
111
112
112
d = {112: 'a', 111: 'b'}
df['B'] = df['A'].map(d)
df
Out[248]:
A B
0 111 a
1 112 b
creating new column with dictionary
In [248]:
dict_ = {112: 'en', 113: 'es', 114: 'es', 111: 'en'}
df['D'] = df['U'].map(dict_)
df
Out[248]:
U L D
0 111 en en
1 112 en en
2 112 es en
3 113 es es
4 113 ja es
5 113 zh es
6 114 es es
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us