Hi,
just finished the small project to show the bar charts for a dataset on Mushrooms. You can find it here:
Git Hub Link
Happy coding!
Hi,
just finished the small project to show the bar charts for a dataset on Mushrooms. You can find it here:
Git Hub Link
Happy coding!
Halo,
this is my mushroom project, I have done the extension too.
any feedback or suggestions are appreciated.
thank you
Hi guys,
Just wanted to add this here in case anyone wanted to take a look:
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import codecademylib3
# load in the data
df = pd.read_csv("mushroom_data.csv")
print(df.head())
# list of all column headers
columns = df.columns.tolist()
# added conditional statement for columns that could be turned into pie charts
for column in columns:
if df[column].nunique() < 6:
plt.pie(df[column].value_counts(), labels = df[column].value_counts().index)
plt.axis("equal")
plt.show()
plt.clf()
else:
sns.countplot(df[column], order = df[column].value_counts().index)
plt.title(f" {column} Value Counts")
plt.xticks(rotation=30, fontsize=10)
plt.xlabel(column, fontsize=12)
plt.show()
plt.clf()
If anyone has any feedback or can help improve my code please let me know!
Hey guys,
Here is the link to my piece of code:
Hello,
For anyone wondering how to use list comprehension to plot the bar charts here’s how:
df_bar_plots = [[sns.countplot(x = df[column]), plt.show(), plt.clf(), plt.xticks(rotation=30, fontsize=10),
plt.xlabel(column, fontsize=12), plt.title(column + ’ Value Counts’)] for column in columns]