I have some data:
ID | Date |
---|---|
1 | 2021-05-01 |
2 | 2021-05-01 |
3 | 2021-05-01 |
4 | -99 |
5 | -99 |
6 | 2017-11-21 |
7 | -99 |
8 | 2019-02-04 |
9 | -99 |
10 | -99 |
Where I have -99, I want to change it to 2021-05-20. I have tried if statement but it won't work, there are still -99s. I have made sure it is a datetime column although thinking about that -99 isn't a datetime value. Maybe that is where I'm going wrong?
df['Date'] = pd.to_datetime(df['Date'], format='%Y-%m-%d')
if (df['Date'] is '-99'):
df['Date'] = pd.Series(['2021-05-20' for x in range(len(df.index))])
I'm thinking the length part is wrong too, since there aren't as many -99 as there are data rows. Thanks in advance for the help!
Aucun commentaire:
Enregistrer un commentaire