Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change Column Type
#1
Good afternoon folks,

I am trying to convert the type of a column from object to time (not datetime)

I am using the following code, which only seems to change the formatting:

df['date_time_info'] = pd.to_datetime(df['date_time_info']).dt.strftime('%H:%M:%S')


However, I also need to set the type to time by using something like. astype('time64') so that the data type is also changed.

I need to use the time to plot a scatter plot

Grateful for any assistance

Thank you
Talch
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Openpyxl-change value of cells in column based on value that currently occupies cells phillipaj1391 5 9,573 Mar-30-2022, 11:05 PM
Last Post: Pedroski55
  type change of dbshelve key between Python 2 and 3 ccaudle 3 2,354 Feb-09-2021, 05:13 PM
Last Post: ccaudle
Question dict value, how to change type from int to list? swissjoker 3 2,692 Dec-09-2020, 09:50 AM
Last Post: perfringo
  How to change row 2 to column header within a dataframe sparkt 2 2,112 Aug-20-2020, 05:12 PM
Last Post: sparkt
  Python - change variable type during program execution ple 1 2,333 Apr-12-2020, 08:43 AM
Last Post: buran
  Type hinting - return type based on parameter micseydel 2 2,426 Jan-14-2020, 01:20 AM
Last Post: micseydel
  How to change a dataframe column to lower case zhujp98 5 6,209 Oct-29-2019, 06:42 PM
Last Post: zhujp98
  change array column values without loop khalidreemy 2 3,694 May-05-2019, 09:05 AM
Last Post: DeaD_EyE
  Change type of elements in a list by column tkj80 7 6,762 Jan-04-2017, 11:15 PM
Last Post: tkj80

Forum Jump:

User Panel Messages

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