Delete a Column From a Pandas DataFrame

Need to delete a column from a Pandas DataFrame to make appending another easier? Did you bring in too much data? I just learned this quick trick and thought I’d pass it on.

Python

import pandas as pd
x=pd.DataFrame()
x['a']=[1,2,3,4]
x['b']=['a','b','c','d']
x.pop('b')
# Where b is the column name

Have a dictionary and need to get it to a DataFrame? Check out this article. Cheers and happy coding!

Leave a Comment Cancel reply

Exit mobile version