'Why the .replace function is not working?
im trying to erase "." from a DataFrame column using the replace function but i have no idea why is not working. The currently column looks like:
Time
5:00 PM
4:00AM
3:30 P.M
2:00 .P.M
What i want is to change that column to a DataTime Hour type , but i think that i need to clean it first. So, in order to do that i want to erase the "." but when i use:
df.Time=df.Time.replace({'.':''})
still does not work. How can i do it?
Solution 1:[1]
You can use:
df.Time=df.Time.apply(lambda x: x.replace('.',''))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sawradip Saha |
