I have a dataframe which consists of 3 colums: 'Date', 'Time' and 'Data' I want to plot 'Date' and 'Time' and the X axis and 'Data' on the Y axis. So far, since I used pandas to import my data set, I tried with:
df.plot(x= "Date", y="Data")
but I think it only allows one argument in 'x='
I also wonder if in this case, is better to define 'Date' and 'Time' as a single column
Thank you for your support!
CodePudding user response:
You can create a new column called "DateTime" that combines "Date" and "Time".
Then plot it on the x axis and "Data" on the y axis:
import pandas as pd
df = ...
df["DateTime"] = pd.to_datetime(df['Date'].astype(str) df['Time'].astype(str), format="%m-%d-%Y%H:%M:%S")
df.plot(x="DateTime", y="Data")