I'm trying to plot columns of a dataframe. There are 9 columns in the DF (the first being the days of the current week, and four pairs of columns after that - each pair representing total_sessions and average session duration.
The first pair of session-data columns is for the current week, the next pair for the previous week, next for the week ending two weeks ago, and the final pair of columns for week ending three weeks ago. I am trying to create two plots, the first for the four weeks of total_sessions data and the second for the four weeks of average session_duration data. Lets call these Plot 1 and Plot2
The python code for plotting Plot 1 and Plot2 using pandas
DataFrame.plot
is as follows:
#PLOT1: CURR WEEK DAILY TOTAL SESSIONS AND ALSO LAST 3 WEEKS
# gca stands for 'get current axis'
ax = plt.gca()
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='IOS_TOTAL_SESSIONS',ax=ax)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM1_IOS_TOTSESSN', color='red', ax=ax)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM2_IOS_TOTSESSN', color='green', ax=ax)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM3_IOS_TOTSESSN', color='cyan', ax=ax)
plt.show()
plt.savefig("iOSWOWAvgDailySessionCount.png")
#PLOT2: CURR WEEK DAILY AVERAGE SESSION DURATION AND ALSO LAST 3 WEEKS
ax2 = plt.gca()
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='IOS_AVG_SESSION_DURATION',ax=ax2)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM1_IOS_AVSESDUR', color='red', ax=ax2)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM2_IOS_AVSESDUR', color='green', ax=ax2)
df_CurrWeekiOSDailySessionCountDuration.plot(kind='line',x='SESSION_DATE',y='WM3_IOS_AVSESDUR', color='cyan', ax=ax2)
plt.show()
plt.savefig("iOSWOWAvgDailySessionDuration.png")
The dataframe has the correct data (as printed below)
However the code just creates the first plot successfully. For the second plot it gives me a "no numeric data to plot" error (see below)
Appreciate any help or pointers on what I am doing wrong/how to fix this.