Skip to content
Advertisement

How to create subplots from each column in a pandas dataframe

I have a dataframe ‘df’ with 36 columns, these columns are plotted onto a single plotly chart and displayed in html format using the code below.

JavaScript

I want to iterate through each column and create a subplot for each one. I have tried;

JavaScript

I created 6 rows and columns as that would give 36 plots and tried to use the header names as subplot titles but I get a ValueError stating it was expecting a 2d list of dictionaries.

Also, I have tried to add subplot titles by;

JavaScript

This also returns an error. Any help is appreciatted.

Advertisement

Answer

Plot:

enter image description here

Code:

JavaScript

Addition: 1-column solution:

Code:

JavaScript

Plots:

enter image description here

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