Reputation: 29
I need to have my column be only integers, but unfortunately the CSV I need to use has the letters T and Z interspersed.
For example:
2022-09-24T00:30:49Z
How would I go about removing these letters for only this one column? I have tried looking elsewhere, but I can't find anything specifically relating to this.
Upvotes: 1
Views: 62
Reputation: 100
def custom_func(x):
if isinstance(x,str):
return x.translate(None,'TZ')
return x
df.col = df.col.apply(custom_func)
You can use applymap method to apply it to each individual cell if you may
Upvotes: 2
Reputation: 589
This question should at least get you started in the right direction: Remove cell in a CSV file if a certain value is there
Upvotes: 1