Skip to content
Advertisement

Plotting values above a threshold in Python

Having issues with plotting values above a set threshold using a pandas dataframe.

I have a dataframe that has 21453 rows and 20 columns, and one of the columns is just 1 and 0 values. I’m trying to plot this column using the following code:

JavaScript
JavaScript

But get the following errors:

JavaScript

Any suggestions on how to fix this?

Advertisement

Answer

The error is probably the result of this line plt.plot(df_smooth['Time'], lst1). While lst1 is a subset of df_smooth[Time], df_smooth['Time'] is the full series.

The solution I would do is to also build a filtered x version for example –

JavaScript

Another option is to build a sub-dataframe –

JavaScript

(assuming the correct column as Y column is Time, otherwise just replace it with the correct column)

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement