Python Forum
Problem with date type (object to datetime)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with date type (object to datetime)
#2
While using read_csv one can pass something like

df = pd.read_csv('my.csv', headers=None, converters={0: lambda x: datetime.datetime.strptime(x, '%d.%m.%Y %H:%M')})
and format as datetime while reading without need to convert it later (if passing headers name then converters key must be corresponding to that header name)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Problem with date type (object to datetime) - by perfringo - Oct-15-2019, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 416 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  pymongo diff type problem to find images on two drives darter 0 1,272 Mar-11-2021, 04:52 AM
Last Post: darter
  replace nan values by mean group by date.year, date.month wissam1974 5 8,332 Feb-19-2020, 06:25 PM
Last Post: AnkitGupta
  Pandas and Date: problem with operator.How to resolve frame 6 4,274 May-13-2019, 05:50 PM
Last Post: frame
  TensorFlow problem in Object Detection yksingh1097 1 2,767 Oct-03-2018, 09:57 PM
Last Post: Larz60+
  Finding date count from a list of date range in pandas trillerducas72 0 2,720 May-24-2018, 02:30 AM
Last Post: trillerducas72

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020