How do generate the same pie chart for pyspark.pandas.frame.DataFrame
?
I'm not able to get the legend right.
piefreq=final_psdf['Target'].value_counts()
piefreq.plot.pie()
For pandas.core.frame.DataFrame
, I managed to produce my desired pie chart using the following code:
piefreq=final_df['Target'].value_counts()
fig=go.Figure(data=[go.Pie(labels=['Yes (n=' + str(piefreq[1]) +')','No (n=' + str(piefreq[0]) +')'],values=final_df['Target'].value_counts())])
fig.update_layout(title={'text': "<b>Pie chart by target</b>",
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'})