pandas dict column code example
Example 1: pandas rename column
df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"}, inplace=True)
Example 2: pandas remove column
del df['column_name']
Example 3: dict column to be in multiple columns python
In [2]: df = pd.DataFrame({'a':[1,2,3], 'b':[{'c':1}, {'d':3}, {'c':5, 'd':6}]})
In [3]: df
Out[3]:
a b
0 1 {u'c': 1}
1 2 {u'd': 3}
2 3 {u'c': 5, u'd': 6}
In [4]: df['b'].apply(pd.Series)
Out[4]:
c d
0 1.0 NaN
1 NaN 3.0
2 5.0 6.0