I have a dataset, df, where I would like to create a new column to my dataset and fill down this column with a specific value
Data
id start stat
d_in din 8
d_in din 8
hello
hi din 8
Desired
plan id start stat
21 d_in din 8
21 d_in din 8
21 hello
21 hi din 8
Doing
df['plan'] = df['plan'].fillna('21')
However, this is not actually creating the new column. Any suggestion is appreciated.
CodePudding user response:
Simply try: df['plan'] = '21'
Or df['plan'] = 21
if an integer type is wanted.
Pandas will automatically broadcast scalars to all rows.