Skip to content

Instantly share code, notes, and snippets.

@smzn
Created January 4, 2024 02:06
Show Gist options
  • Save smzn/d40ae7adbad91fe42395d22a6b9fd80d to your computer and use it in GitHub Desktop.
Save smzn/d40ae7adbad91fe42395d22a6b9fd80d to your computer and use it in GitHub Desktop.
histograms for each categorical column
# Selecting categorical columns
categorical_columns = df[['rideable_type', 'member_casual']]
# Creating histograms for each categorical column
plt.figure(figsize=(12, 6))
# Rideable Type
plt.subplot(1, 2, 1)
df['rideable_type'].value_counts().plot(kind='bar', color='skyblue')
plt.title('Rideable Type Frequency')
plt.xlabel('Rideable Type')
plt.ylabel('Frequency')
plt.xticks(rotation=0)
plt.grid(axis='y')
# Member Casual
plt.subplot(1, 2, 2)
df['member_casual'].value_counts().plot(kind='bar', color='green')
plt.title('Member vs Casual Frequency')
plt.xlabel('Member Type')
plt.ylabel('Frequency')
plt.xticks(rotation=0)
plt.grid(axis='y')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment