squar_o
squar_o

Reputation: 567

pandas df.plot.scatter fails but df.plot produces plot

I want to produce scatter plots of data from a pandas df, sample below. enter image description here I can produce line plots with:

ax = df_stats.plot(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot(x='t',y='t_TI_var_pwr',ax=ax1, color='g')

enter image description here

but when I try to use .scatter to plot the same data as a scatter plot I get the error KeyError: 't'

ax = df_stats.plot.scatter(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot.scatter(x='t',y='t_TI_var_pwr',ax=ax1, color='g')

Upvotes: 1

Views: 55

Answers (1)

user1885349
user1885349

Reputation: 392

It seems that your column to is a timestamp. To use scatter it must be a float. You can plot scatter plot with:

ax = df_stats.plot(x = 't', y='t_TI_var_pwr',style='o')      

Upvotes: 1

Related Questions