Created
January 4, 2024 01:56
-
-
Save smzn/098114fab724eda7a77186c596d0cd0d to your computer and use it in GitHub Desktop.
histograms for each of the latitude and longitude columns
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
import matplotlib.pyplot as plt | |
# Creating separate histograms for each of the latitude and longitude columns | |
df = divvy_tripdata | |
plt.figure(figsize=(12, 8)) | |
# Start Latitude | |
plt.subplot(2, 2, 1) | |
plt.hist(df['start_lat'], bins=30, color='skyblue', edgecolor='black') | |
plt.axvline(df['start_lat'].mean(), color='red', linestyle='dashed', linewidth=1) | |
plt.title('Start Latitude') | |
plt.xlabel('Start Latitude') | |
plt.ylabel('Frequency') | |
plt.grid(True) | |
# Start Longitude | |
plt.subplot(2, 2, 2) | |
plt.hist(df['start_lng'], bins=30, color='green', edgecolor='black') | |
plt.axvline(df['start_lng'].mean(), color='red', linestyle='dashed', linewidth=1) | |
plt.title('Start Longitude') | |
plt.xlabel('Start Longitude') | |
plt.grid(True) | |
# End Latitude | |
plt.subplot(2, 2, 3) | |
plt.hist(df['end_lat'].dropna(), bins=30, color='blue', edgecolor='black') # Drop NA values for end_lat | |
plt.axvline(df['end_lat'].mean(), color='red', linestyle='dashed', linewidth=1) | |
plt.title('End Latitude') | |
plt.xlabel('End Latitude') | |
plt.ylabel('Frequency') | |
plt.grid(True) | |
# End Longitude | |
plt.subplot(2, 2, 4) | |
plt.hist(df['end_lng'].dropna(), bins=30, color='purple', edgecolor='black') # Drop NA values for end_lng | |
plt.axvline(df['end_lng'].mean(), color='red', linestyle='dashed', linewidth=1) | |
plt.title('End Longitude') | |
plt.xlabel('End Longitude') | |
plt.grid(True) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment