Answers for "create new column using dictionary padnas"

1

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
Posted by: Guest on March-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language