Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
1.2 kB
4
Indexable
Never
import pandas as pd

# Assuming you have the data in a DataFrame named 'food_prices'
# You can create a DataFrame as follows:
data = {
    "Date": pd.date_range(start="2017-12-01", end="2023-11-01", freq="M"),
    "Beef_Striploin_Price": [
        18.07, 16.62, 20.00, 23.06, 18.22, 19.07, 20.39, 21.00, 19.47, 21.90, 19.94, 18.85,
        14.08, 19.79, 19.08, 21.56, 17.32, 19.94, 20.72, 20.32, 19.11, 18.13, 18.41, 17.42,
        18.29, 20.08, 18.96, 20.92, 19.16, 23.63, 31.62, 24.03, 24.58, 20.73, 23.22, 20.27,
        18.43, 22.38, 21.52, 24.69, 22.87, 23.38, 25.53, 26.89, 27.82, 23.12, 26.70, 24.05,
        21.53, 26.55, 26.97, 32.72, 28.80, 24.32, 24.19, 23.27, 22.91, 26.25, 23.51, 21.21,
        19.53, 27.98, 23.32, 27.70, 27.08, 26.87, 26.04, 32.11, 26.22, 27.67, 25.47, 23.95
    ],
}

food_prices = pd.DataFrame(data)

# Create a frequency distribution table
price_intervals = pd.cut(food_prices['Beef_Striploin_Price'], bins=range(10, 36, 5), include_lowest=True)
frequency_table = pd.value_counts(price_intervals, sort=False).reset_index()
frequency_table.columns = ['Price Range', 'Frequency']

# Display the frequency distribution table
print(frequency_table)
Leave a Comment