Skip to main content

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

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.1.tar.gz (7.3 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.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bharatutils-0.1.1.tar.gz
  • Upload date:
  • Size: 7.3 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.1.tar.gz
Algorithm Hash digest
SHA256 893d038cef11e1100ba1400c08e307dfbcf7d9324bec408d7c64ff2f0f860f23
MD5 bf9bcb42d68785f0d447fef6626cacc9
BLAKE2b-256 9fd8cf4946a31087c365d31e37a4be9e18a35bcd0535e2ffb959d1f5cfb12c76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bharatutils-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ee58132b8d284532a2c499529b76241b650ffe004d39daf6e5c1b9c911e4b6e
MD5 31cfafcb52888c23e630df32a11a396f
BLAKE2b-256 9fbb5403789a0810cd54c99f9b5e4016439cb5456c6b7873aad4b535fa4f96ca

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