0% found this document useful (0 votes)
16 views4 pages

Python Code Used For The Analysis Along With Data Visualizations

The document contains Python code for analyzing a dataset related to bookings, including visualizations of booking trends, top revenue-generating destinations, and the impact of coupon usage on profitability. It utilizes libraries such as pandas, matplotlib, and seaborn for data manipulation and visualization. Key insights include monthly revenue trends, the top 10 destinations by revenue, and average profit margins based on coupon usage.

Uploaded by

vikash21ug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Python Code Used For The Analysis Along With Data Visualizations

The document contains Python code for analyzing a dataset related to bookings, including visualizations of booking trends, top revenue-generating destinations, and the impact of coupon usage on profitability. It utilizes libraries such as pandas, matplotlib, and seaborn for data manipulation and visualization. Key insights include monthly revenue trends, the top 10 destinations by revenue, and average profit margins based on coupon usage.

Uploaded by

vikash21ug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python code used for the analysis along with data

visualizations.

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

# Load Dataset

file_path = "Dataset - 3.csv"

df = pd.read_csv(file_path)

# Convert date columns to datetime

df["Booking date"] = pd.to_datetime(df["Booking date"])

df["travel_date"] = pd.to_datetime(df["travel_date"])

# Identify Observations

# 1. Booking trends over time

df['Booking Month'] = df["Booking date"].dt.to_period("M")

booking_trends = df.groupby("Booking Month")["selling_price"].sum()

# 2. Top revenue-generating destinations

top_destinations =
df.groupby("Destination")["selling_price"].sum().sort_values(ascending=False).head(10)

# 3. Impact of coupon usage on profitability

df["profit"] = df["selling_price"] - df["costprice"]

df["profit_margin"] = (df["profit"] / df["selling_price"]) * 100

coupon_analysis = df.groupby("Coupon Used?")["profit_margin"].mean()

# Create Visualizations

plt.figure(figsize=(12, 5))
booking_trends.plot(marker="o", color="b", linestyle="-")

plt.xlabel("Month")

plt.ylabel("Total Revenue (Selling Price)")

plt.title("Monthly Revenue Trend")

plt.xticks(rotation=45)

plt.grid(True)

plt.show()

plt.figure(figsize=(12, 5))

sns.barplot(x=top_destinations.index, y=top_destinations.values, palette="viridis")

plt.xlabel("Destination")

plt.ylabel("Total Revenue (Selling Price)")

plt.title("Top 10 Destinations by Revenue")

plt.xticks(rotation=45)

plt.show()

plt.figure(figsize=(8, 5))

sns.barplot(x=coupon_analysis.index, y=coupon_analysis.values, palette="coolwarm")

plt.xlabel("Coupon Used?")

plt.ylabel("Average Profit Margin (%)")

plt.title("Impact of Coupon Usage on Profit Margin")

plt.ylim(0, max(coupon_analysis) + 5)

plt.show()

Visualisations
1.Booking trends over time
2.Revenue distribution by destination

3.Impact of coupon usage on profitability

You might also like