Skip to main content

Python utilities for Indian developers — lakh/crore formatting, GST & PAN validation, address parsing, festival calendar

Reason this release was yanked:

Broken __init__.py — use 0.1.1+

Project description

bharatutils 🇮🇳

Python utilities for Indian developers — because 1,500,000 should display as ₹15 L.

Lakh/crore formatting · GST & PAN validation · Address parsing · Festival calendar

Why?

Every Indian developer has written these same utility functions a hundred times:

# Without bharatutils 😩
df["salary_display"] = df["salary"].apply(
    lambda x: f"₹{round(x/100000, 2)} L" if x >= 100000 else f"₹{x:,}"
)  # ...and it crashes on NaN

# With bharatutils 😎
from bharatutils import format_inr
df["salary_display"] = df["salary"].apply(format_inr)   # handles NaN, strings, negatives

Install

pip install bharatutils

Features

💰 Indian number formatting

from bharatutils import format_inr, to_lakh, to_crore

format_inr(1500000)     # '₹15.0 L'
format_inr(50000000)    # '₹5.0 Cr'
format_inr("15,00,000") # '₹15.0 L'  — handles messy strings
to_lakh(1500000)        # 15.0

🧾 GST validation — with real checksum

from bharatutils import validate_gstin_strict, parse_gstin

validate_gstin_strict("27AAAPZ2318J1ZI")  # True — verifies the check digit
parse_gstin("27AAAPZ2318J1ZI")
# {'state': 'Maharashtra', 'pan': 'AAAPZ2318J', 'entity_number': '1', ...}

Catches single-character typos that format-only validators miss.

🪪 PAN validation + holder type

from bharatutils import parse_pan

parse_pan("AAAPZ2318J")
# {'holder_type': 'Individual', 'is_individual': True, ...}
# P=Person, C=Company, T=Trust, G=Government...

📍 Indian address parsing

from bharatutils import parse_address

parse_address("Flat 302, Nr. SBI ATM, MG Road, Pune - 411001")
# {'pincode': '411001', 'state': 'Maharashtra', 'city': 'Pune'}

Handles space-broken pincodes ("700 016"), ignores phone numbers, never crashes.

🪔 Festival calendar

from bharatutils import next_festival, days_until

next_festival()        # {'name': 'Muharram', 'date': datetime.date(2026, 6, 26)}
days_until("Diwali")   # 150

Covers Hindu, Muslim, Christian, Sikh & Jain festivals plus national holidays — verified against official Government of India lists.

Status

v0.1.0 — early but tested. Pincode→state mapping is prefix-based (~95% accurate); exact-lookup coming in v0.2.

Found a bug? Open an issue — responses are fast.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bharatutils-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bharatutils-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file bharatutils-0.1.0.tar.gz.

File metadata

  • Download URL: bharatutils-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bharatutils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdd009224d852c47562fef11bccccdb863a25a6ed754652111690f3669696098
MD5 3c0b1b6783416f9de9ca32c8e0bf0bb0
BLAKE2b-256 d03162a98e78ff4bd3ee591f61194a50d72e7d4831f803d7849203132ccbee91

See more details on using hashes here.

File details

Details for the file bharatutils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bharatutils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bharatutils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 761c60f7ba0a4f78448c509ed36cecda7759cfec3374c7672e1c46b2f437cf03
MD5 19776a951108655a6d6df7a5ae9e638a
BLAKE2b-256 e01b2aa5d8265e0b15f087c470b340e14e034254d1235977f8eb79b366ecaa0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page