How to fill new values in a dataframe based on some condition from other column
For eg. I want to fill the rows which have the time as 11:30 in y column with value 1 in regressor column, while those dates having time 11:25 should be filled with value 2 in regressor column.
How to do this?
The type of input_df["ds"] column is pandas.core.series.Series
input_df
ds y regressor
0 2019-10-04 11:30:00 a 0
1 2019-10-04 11:35:00 b 0
2 2019-10-04 11:40:00 c 0
3 2019-10-04 11:25:00 d 0
4 2019-10-04 11:50:00 e 0
.
.
.
n 2019-14-04 11:50:00 f 0
output_df
ds y regressor
0 2019-10-04 11:30:00 a 1
1 2019-10-04 11:35:00 b 0
2 2019-10-04 11:40:00 c 0
3 2019-10-04 11:25:00 d 2
4 2019-10-04 11:50:00 e 0
.
.
.
n 2019-14-04 11:50:00 f 0
'''
Aucun commentaire:
Enregistrer un commentaire