This has already been asked, but I tried it in proper way, and somehow I am getting an unexpected result.
I have two dataframes data and dky with many columns.
The code,
data.loc[(data['source'] == 'DKY_2016'), 'seconds']
returns:
1147 22.80
1154 44.90
1160 45.00
1161 58.35
1162 2.45
I want to replace the aforementioned column with dky['seconds'], which contains:
0 41.22
1 22.80
2 44.90
3 45.00
4 58.35
I tried the following code data.loc[(data['source'] == 'DKY_2016'), 'seconds'] = dky['seconds'].
But it only giving the NaN as the output column
1147 NaN
1154 NaN
1160 NaN
1161 NaN
1162 NaN
What I am doing wrong here?
data.loc[(data['source']=='DKY_2016'),'seconds']=dky['seconds'].values.tolist()