I a dataframe with columns that have a combination of int and str value in which I need to replace the value to 0. I have tried using replace to do this, but for some reason it will not work.
I could simply do this using the Find and Replace function in excel prior to importing the csv, but why do this when a funtion could simply perform the task without the added extra work. I have referred to the post below, but still nothing works.
Pandas replacing elements not working
below is the code that I have used
crew_hours1 = pd.Series(crew_data.loc[:, 'Crew/Equip 1 Hours'])
crew_hours1.replace('<Not-Defined>', '0')
When I print the result the following output is returned:
0 4
1 4
2 <Not Defined>
3 6
4 2
...
134 <Not Defined>
135 <Not Defined>
136 <Not Defined>
137 <Not Defined>
138 <Not Defined>
For some reason it will not work. I have used both inplace = True and regex = True, but still fails to work. Does anyone have a solution for this?