Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Column To Time
#1
Hi All,

Am a newbie in python looking for some help.

I have imported a csv with my data and one of the columns has a date time stamp. As a dataframe, this is being read as type object.

How do I convert that column into time (or create a new column from the date time stamp which shows just time) without the date so that I can plot a graph based on the times.

Thank you.

Talch
Reply
#2
It would be easier if you post also your code. You can use apply function to convert your column to datetime, so it would look something like this:
from datetime import datetime
df['timestamp'] = df['timestamp'].apply(lambda x: datetime.strptime(x, '%Y-%m-%d %H:%M:%S'))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot convert the series to <class 'int'> when trying to create new dataframe column Mark17 3 8,539 Jan-20-2022, 05:15 PM
Last Post: deanhystad
  Convert looping home security to a one time scan of switches and sensors duckredbeard 0 1,755 Dec-08-2020, 04:31 AM
Last Post: duckredbeard
  Convert to UTC without changing time pythonlearner1 1 2,117 Nov-05-2020, 09:54 PM
Last Post: pythonlearner1
  Convert quarterly time series to monthly time series donnertrud 1 5,189 May-22-2020, 10:16 AM
Last Post: pyzyx3qwerty
  Convert weekly sequences to date and time. SinPy 0 1,451 Nov-23-2019, 05:20 PM
Last Post: SinPy
  Parse Binary Data File and convert Epoch Time drdevereaux 1 3,191 May-16-2019, 01:56 AM
Last Post: Larz60+
  Convert from datetime to time.struct_time object chris0147 0 4,374 Mar-11-2018, 12:01 AM
Last Post: chris0147
  Time Difference in Epoch Microseconds then convert to human readable firesh 4 11,644 Feb-27-2018, 09:08 AM
Last Post: firesh
  Convert from time.struct_time to a string chris0147 2 7,746 Feb-22-2018, 04:53 PM
Last Post: chris0147

Forum Jump:

User Panel Messages

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