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
JavaScript
x
7
1
id start stat
2
d_in din 8
3
d_in din 8
4
hello
5
hi din 8
6
7
Desired
JavaScript
1
6
1
plan id start stat
2
21 d_in din 8
3
21 d_in din 8
4
21 hello
5
21 hi din 8
6
Doing
JavaScript
1
2
1
df['plan'] = df['plan'].fillna('21')
2
However, this is not actually creating the new column. Any suggestion is appreciated.
Advertisement
Answer
Simply try: df['plan'] = '21'
Or df['plan'] = 21
if an integer type is wanted.
Pandas will automatically broadcast scalars to all rows.