0

I am reading in a CSV file with separate columns for year, month, day, hour, minute, second and would like to know how to combine the time columns (hour, minute, second) into a readable timestamp so I can plot data versus time.

This is my CSV file data.head(10):

     flt  yr  month  day  hr  ...   
0    1  2018      1   17  16  ...         
1    1  2018      1   17  16  ...         
2    1  2018      1   17  16  ...           
3    1  2018      1   17  16  ...           
4    1  2018      1   17  16  ...           
5    1  2018      1   17  16  ...           
6    1  2018      1   17  16  ...         
7    1  2018      1   17  16  ...         
8    1  2018      1   17  16  ...          
9    1  2018      1   17  16  ...         

I expect the outcome to be, for example, a timestamp of 16:45:13.

Jake P
  • 480
  • 3
  • 19
Natasha
  • 101
  • 1
  • 12

1 Answers1

1
dataframe["time"] = dataframe["hour"].map(str) + ":" + dataframe["minute"].map(str) + ":" + dataframe["second"].map(str)

source another example

Jake P
  • 480
  • 3
  • 19