Streamlit did not show the pie chart by df.plot.pie command

Dear Boss
Please review my code; it did not display the pie chart and returned an error. I would appreciate any suggestions on how I can generate the pie chart using the data from the DataFrame.

import plotly.express as px

import matplotlib.pyplot as plt

import pandas as pd

import streamlit as st

import numpy as np

df5 = pd.DataFrame( 3 * np.random.rand(4, 2), index=[“a”, “b”, “c”, “d”], columns=[“x”, “y”])

st.write(df5)

st.pyplot(df5.plot.pie(subplots=True, figsize=(8, 4)).figure)

The following should give you the pie charts.

df5.plot.pie(subplots=True, figsize=(8, 4))

st.pyplot(plt.gcf())

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.