0

Here is my problem: I have a pandas DataFrame with 15 minutes acquisition and a timestamp of 0.05 s.

The column time is a datetime format and following this format :(YYYY-mm-dd HH:MM:SS %.f) with %.f is microsecond.

I want to have a plot of the data and I tried this code :

plt.plot(WaveLab_df['Time'],WaveLab_df['Mecanical_Power_Starboard'],'g--')
plt.xlabel('Time')
plt.ylabel('Power (W)')

But I have this figure :

enter image description here

As you can see I have only 3 x axis points. What I would like is to have at least one each minute.

I tried also the following code in order to make my own x axis:

base=WaveLab_df.loc[0,'Time']
date_range=[base+dt.timedelta(minutes=x) for x in range(0,15,3)]
plt.plot(WaveLab_df['Time'],WaveLab_df['Mecanical_Power_Starboard'],'g--')
plt.xticks(date_range)
plt.xlabel('Time')
plt.ylabel('Power(W)')

But I obtained this figure:

enter image description here

DavidG
  • 24,279
  • 14
  • 89
  • 82
Nathan
  • 29
  • 1
  • 7
  • My guess is that pandas takes the first value available for each element from your date_range. You might want to store the time values alone using .time() on your sum instead of datetime values. This might help you; https://stackoverflow.com/questions/4049825/how-to-get-the-sum-of-timedelta-in-python and https://stackoverflow.com/questions/4049825/how-to-get-the-sum-of-timedelta-in-python – Ando Jurai Aug 01 '17 at 11:55
  • I tried with what you said but it didn't work :/ But finally I changed my column time and put it in seconds it was easier. thanks :) – Nathan Aug 14 '17 at 09:30

0 Answers0