Menu

Analyzing Numerical and Categorical Data

Analyzing Numerical and Categorical Data

Datasets commonly contain numerical variables, such as price and sales, alongside categorical variables, such as region and product type. Each requires a slightly different analytical approach.

Analyzing Numerical Variables

Numerical summaries help describe the typical value, variability, and range of a variable.

print("Average units sold:", df["Units_Sold"].mean())

print("Median units sold:", df["Units_Sold"].median())

print("Minimum units sold:", df["Units_Sold"].min())

print("Maximum units sold:", df["Units_Sold"].max())

print("Standard deviation:", df["Units_Sold"].std())

The mean represents the arithmetic average, while the median represents the middle value after sorting. The standard deviation describes how spread out observations are around the mean.

The median can be more representative than the mean when the data contains extreme values.

Analyzing Categorical Variables

Categorical analysis helps reveal which groups appear most frequently.

print(df["Product"].value_counts())

print(df["Region"].value_counts())

You can also calculate the proportion of records belonging to each category.

print(df["Product"].value_counts(normalize=True) * 100)

This returns the percentage of records associated with each product.

Frequency counts are useful for understanding customer segments, product categories, locations, and other groups before comparing their performance.


Python for Data Science

VA

Vishalini A



Learn via Video Course

undefined Logo

NaN hrs



Get in Touch For Details