Python Forum
pandas.to_datetime: Combine data from 2 columns
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas.to_datetime: Combine data from 2 columns
#2
Something like below?

import pandas as pd

df = pd.read_csv('minimal_in.csv')

df['Datetime'] = pd.to_datetime(df['Year'] + df['Time'], format='%d.%m.%Y%H:%M:%S')
df will look like:

Output:
Year Time Datetime 0 29.01.2001 13:31:24 2001-01-29 13:31:24 1 29.01.2001 13:31:27 2001-01-29 13:31:27 2 29.01.2001 13:31:29 2001-01-29 13:31:29 3 29.01.2001 13:31:32 2001-01-29 13:31:32 4 29.01.2001 13:31:34 2001-01-29 13:31:34
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: pandas.to_datetime: Combine data from 2 columns - by perfringo - Feb-20-2021, 08:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Grouping in pandas/multi-index data frame Aleqsie 3 695 Jan-06-2024, 03:55 PM
Last Post: deanhystad
Smile How to further boost the data read write speed using pandas tjk9501 1 1,275 Nov-14-2022, 01:46 PM
Last Post: jefsummers
Thumbs Up can't access data from URL in pandas/jupyter notebook aaanoushka 1 1,879 Feb-13-2022, 01:19 PM
Last Post: jefsummers
Question Sorting data with pandas TheZaind 4 2,362 Nov-22-2021, 07:33 PM
Last Post: aserian
  Pandas Data frame column condition check based on length of the value aditi06 1 2,704 Jul-28-2021, 11:08 AM
Last Post: jefsummers
  import columns of data from local csv file CatherineKan 2 3,355 May-10-2021, 05:10 AM
Last Post: ricslato
  iretate over columns in df and calculate euclidean distance with one column in pandas Pit292 0 3,313 May-09-2021, 06:46 PM
Last Post: Pit292
  [Pandas] Write data to Excel with dot decimals manonB 1 5,912 May-05-2021, 05:28 PM
Last Post: ibreeden
  Remove extra count columns created by pandas groupby spyf8 1 2,740 Feb-10-2021, 09:19 AM
Last Post: Naheed
  Combine groupby() and shift() in pandas rama27 0 4,228 Nov-17-2020, 09:49 PM
Last Post: rama27

Forum Jump:

User Panel Messages

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