Created
January 4, 2024 02:06
-
-
Save smzn/d40ae7adbad91fe42395d22a6b9fd80d to your computer and use it in GitHub Desktop.
histograms for each categorical column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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