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.
- 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%.
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 .
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.
To run the tests, you can install the test dependencies:
pip install .[test]
This will install pytest and any other testing-related packages.
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.
src/
├── ambrosial/
│ ├── swan/
│ ├── swich/
│ └── swiggy/
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)
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()
Now you can use the SwiggyChart
instance to create various visualizations:
# Create a bar plot of top 10 most ordered items
swich.barplot.restaurant_deltime()
# Create a calendar plot showing order frequency
swich.calplot.order_count()
# Create a GitHub-style map of order history
swich.ghubmap.order_amount()
# Create a heat map of order timings
swich.heatmap.order_count()
# Create an interactive map of order locations
swich.map.count_density()
# Create a regression plot of order values over time
swich.regplot.ordamt_ordfee()
# Create a word cloud of restaurant names
swich.wcloud.restaurant_name()
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)
)
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()
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.
This project is licensed under the MIT License - see the LICENSE file for details.