Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

python - Remove date from datetime in csv

for a project in python we need to use a csv file with several columns and create a ML model. My problem is, that one column is datetime, and the date is useless for the predictions, but i don't know how to remove it, as it is in the same column with the time like (so I can't just drop the column):

26.03.2018 00:00:00

Can you help me remove the date somehow? I tried different methods for handling 'datetime' but non worked so far.

data = pd.read_csv("TotalTrafo.csv")
dir(data)

type(data.Trafo1)

pandas.core.series.Series

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just do:

df['DateTime column']=df['DateTime column'].dt.time

to get only time .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...