You want to add an empty column to a pandas dataframe.
Let’s read a dataset to illustrate.
import pandas as pd import numpy as np url = 'https://raw.githubusercontent.com/bprasad26/lwd/master/data/Restaurant.csv' df = pd.read_csv(url) df.head()
Now, let’s say I want to add an empty column location to this dataframe. To do that I will just create a new column and fill it with np.nan.
df['location'] = np.nan