import pandas as pd

retail = pd.read_csv("Retail_Transaction_Dataset.csv")

retail.columns = retail.columns.str.strip()

retail["TransactionDate"] = pd.to_datetime(retail["TransactionDate"], errors="coerce")

for column in ["Price", "Quantity", "TotalAmount", "DiscountApplied(%)"]:
    retail[column] = pd.to_numeric(retail[column], errors="coerce")

retail.shape

retail.info()

retail.describe()

retail.isna().sum()

retail.duplicated().sum()

retail["TransactionDate"] = pd.to_datetime(retail["TransactionDate"])

retail.dtypes

retail["Month"] = retail["TransactionDate"].dt.month

retail["Month"].value_counts()

top_products = retail["ProductCategory"].value_counts()

top_products

Quantity = retail.groupby("ProductCategory")["Quantity"].sum().reset_index()

Quantity

retail.groupby("StoreLocation")["TotalAmount"].sum()

retail[retail["DiscountApplied(%)"] > 12].count()

retail.groupby("PaymentMethod")["Quantity"].mean()

retail["DiscountAmount"] = (retail["Price"]) * retail["DiscountApplied(%)"] / 100

retail.head()

retail["EffectivePrice"] = retail["Price"] - retail["DiscountAmount"]

retail

retail["Revenue"] = retail["EffectivePrice"] * retail["Quantity"]

retail

retail["TransactionDay"] = retail["TransactionDate"].dt.day_name()

retail

retail.groupby("TransactionDay")["Revenue"].sum()

retail[(retail["PaymentMethod"] == "Cash") & (retail["TotalAmount"] > 60)]
