Skip to content

Fetch, analyze and visualize your Swiggy order history!

License

Notifications You must be signed in to change notification settings

DistilledCode/ambrosial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ambrosial: Swiggy Order History Analysis Package

Ambrosial is an Object-Oriented Programming (OOP) based installable Python package designed for comprehensive analysis of Swiggy order history data. This package offers a robust set of features for fetching, processing, and visualizing order data from the popular food delivery platform Swiggy.

Features

  • Automated Data Retrieval: Utilizes browser-cookies to fetch and update Swiggy order history automatically.
  • Data Preprocessing: Handles data preprocessing, loading, caching, and conversion to DataClasses.
  • Comprehensive Analysis: Generates analysis in both textual format and through various types of graphs.
  • Visualization Options: Supports multiple graph types including Barplots, CalendarPlots, HeatMaps, Interactive Location HeatMaps, Word Clouds, Scatterplots, and Regression Lines.
  • High-Quality Code: 100% type-annotated code with test coverage of more than 80%.

Installation

git clone https://github.com/DistilledCode/ambrosial.git
cd ambrosial
python -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
pip install .

Additional Installation Options

Installing with development dependencies

If you want to contribute to the project or run tests, you can install the development dependencies:

pip install .[dev]

This will install additional packages for development, including pre-commit hooks, linters, and formatters.

Installing with test dependencies

To run the tests, you can install the test dependencies:

pip install .[test]

This will install pytest and any other testing-related packages.

Verifying the Installation

After installation, you can verify that Ambrosial is correctly installed by running:

python -c "import ambrosial; print(ambrosial.__version__)"

This should print the version number of Ambrosial.

Project Structure

src/
├── ambrosial/
│   ├── swan/
│   ├── swich/
│   └── swiggy/

Basic Setup

Tip

You can also refer to advanced examples

To start using the package, import the necessary modules and create instances of the main classes:

from ambrosial.swiggy import Swiggy
from ambrosial.swan import SwiggyAnalytics
from ambrosial.swich import SwiggyChart

# Create instances
swiggy = Swiggy()
swan = SwiggyAnalytics(swiggy)
swich = SwiggyChart(swan)

Fetching and Loading Data

Before creating visualizations, you need to fetch or load your Swiggy order data:

# Fetch new data (if you haven't already)
swiggy.fetch_orders()
swiggy.saveb()  # Save data for future use

# Or load previously saved data
swiggy.loadb()

Creating Visualizations

Now you can use the SwiggyChart instance to create various visualizations:

1. Bar Plot

# Create a bar plot of top 10 most ordered items
swich.barplot.restaurant_deltime()

Bar Plot Example

2. Calendar Plot

# Create a calendar plot showing order frequency
swich.calplot.order_count()

Calendar Plot Example

3. GitHub-style Contribution Map

# Create a GitHub-style map of order history
swich.ghubmap.order_amount()

GitHub-style Map Example

4. Heat Map

# Create a heat map of order timings
swich.heatmap.order_count()

Heat Map Example

5. Interactive Location Map

# Create an interactive map of order locations
swich.map.count_density()

Interactive Map Example

6. Regression Plot

# Create a regression plot of order values over time
swich.regplot.ordamt_ordfee()

Regression Plot Example

7. Word Cloud

# Create a word cloud of restaurant names
swich.wcloud.restaurant_name()

Word Cloud Example

Customizing Visualizations

Many visualization methods allow for customization. For example:

# Customize the bar plot
swich.barplot.top_items(
    top_n=15,
    title="Top 15 Most Ordered Items",
    color_palette="viridis"
)

# Customize the heat map
swich.heatmap.order_timings(
    cmap="YlOrRd",
    title="Order Timing Heatmap",
    figsize=(12, 8)
)

Combining with Analytics

You can use the SwiggyAnalytics instance to get data for custom visualizations:

# Get top restaurants data
top_restaurants = swan.restaurants.top_restaurants(top_n=5)

# Use this data to create a custom visualization
import matplotlib.pyplot as plt

plt.figure(figsize=(10, 6))
plt.bar(top_restaurants['name'], top_restaurants['order_count'])
plt.title("Top 5 Most Ordered From Restaurants")
plt.xlabel("Restaurant Name")
plt.ylabel("Number of Orders")
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()

Saving Visualizations

Most visualization methods in the SwiggyChart class likely have options to save the generated plots. For example:

swich.barplot.top_items(top_n=10, save_path="top_items.png")
swich.calplot.order_frequency(save_path="order_frequency.svg")

Remember to check the documentation or source code of each visualization method for specific parameters and options available.

Example Visualizations

Order Total vs. Order Fee Relationship

Scatterplot Example 1

Punctuality vs. Order Delivery Time

Scatterplot Example 2

Order Total vs. Order Fee Relationship

Scatterplot Example 3

Average Delivery Times for Various Restaurants

Barplot Example 1

Average Amount Spent on Menu Items

Barplot Example 2

Average Spending at Various Restaurants

Barplot Example 3

Weekly Order Count and Amount Heatmaps

Heatmap Example 1

Heatmap Example 2

Total Offer Availed Calendar for January 2022

Heatmap Example 3

Order Count, Discount, and Spending Trends (2021-2022)

Calendar Plot - Total Order Count Calendar Plot - Total Discount Calendar Plot - Total Amount Spent

Monthly Amount Spent Heatmap Calendar View

Calendar Plot - Total Amount Calculated

Monthly Order Count Heatmap Calendar View

Calendar Plot - Order Count

Cuisine Word Cloud

Word Cloud - Restaurant Cuisine

Item Name Word Cloud

Word Cloud - Item Names

Restaurant Name Word Cloud

Word Cloud - Restaurant Names

License

This project is licensed under the MIT License - see the LICENSE file for details.