Untitled
unknown
python
13 days ago
625 B
1
Indexable
Never
import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy.stats import poisson df = pd.read_csv('deliveries.csv') df['time_stamp'] = pd.to_datetime(df['time_stamp']) df['hour'] = df['time_stamp'].dt.hour order_counts = df['hour'].value_counts().sort_index() lambda_value = order_counts.mean() x = np.arange(0, order_counts.max() + 1) pmf = poisson.pmf(x, lambda_value) plt.bar(x, pmf) plt.title('Poisson Distribution of Pizza Orders Per Hour') plt.xlabel('Number of Orders') plt.ylabel('Probability') plt.xticks(x) plt.show() print(f'Average number of orders per hour: {lambda_value:.2f}')
Leave a Comment