Skip to main content

A Pandas extension to make work with Jalali Date easier.

Project description

HitCount PyPI - Downloads PyPI version Code style: black codecov License: GPL v3 Open In Colab GitHub Repo stars

Jalali Pandas Extentsion

A pandas extension that solves all problems of Jalai/Iraninan/Shamsi dates

Jalali Pandas python package

Features

Series Extenstion

  • Convert string to Jalali date 1388/03/25 --> jdatetime(1388,3,25,0,0)
  • Convert gregorian date to Jalali date datetime(2019,11,17,0,0) --> jdatetime(1398,8,26,0,0)
  • Convert Jalali date to gregorian date jdatetime(1398,10,18,0,0) --> datetim(2020,1,8,6,19)

DataFrame extenstion

  • Support grouping by Jalali date
  • Group by year, month, days, ...
  • Shortcuts for groups: ymd for ['year','month','day'] and more
  • Resampling: Convenience method for frequency conversion and resampling of time series but in Jalali dateformat. (comming soon)

Installation

pip install -U jalali-pandas

Usage

Just import jalali-pandas and use pandas just use .jalali as a method for series and dataframes. Nothin outside pandas.

jalali-pandas is an extentsion for pandas, that add a mehtod for series/columns and dataframes.

Series

import pandas as pd
import jalali_pandas

# create dataframe
df = pd.DataFrame({"date": pd.date_range("2019-01-01", periods=10, freq="D")})

# convert to jalali
df["jdate"] = df["date"].jalali.to_jalali()

# convert to gregorian
df["gdate"] = df["jdate"].jalali.to_gregorian()

# parse string to jalali
df1 = pd.DataFrame({"date": ["1399/08/02", "1399/08/03", "1399/08/04"]})
df1["jdate"] = df1["date"].jalali.parse_jalali("%Y/%m/%d")


# get access to jalali year,quarter ,month, day and weekday
df['year'] = df["jdate"].jalali.year
df['month'] = df["jdate"].jalali.month
df['quarter'] = df["jdate"].jalali.quarter
df['day'] = df["jdate"].jalali.day
df['weekday'] = df["jdate"].jalali.weekday

DataFrame

import pandas as pd
import jalali_pandas

df = pd.DataFrame(
    {
    "date": pd.date_range("2019-01-01", periods=10, freq="M"),
    "value": range(10),
    }
)
# make sure to create a column with jalali datetime format. (you can use any name)
df["jdate"] = df["date"].jalali.to_jalali()


# group by jalali year
gp = df.jalali.groupby("year")
gp.sum()

#group by month
mean = df.jalali.groupby('mean')

#groupby year and month and day
mean = df.jalali.groupby('ymd')
# or
mean = df.jalali.groupby(['year','month','day'])


#groupby year and quarter
mean = df.jalali.groupby('yq')
# or
mean = df.jalali.groupby(['year','quarter'])

راهنمای فارسی

برای مطالعه راهنمای فارسی استفاده از کتابخانه به این آدرس مراجعه کنید.

معرفی بسته pandas-jalali | آموزش کار با تاریخ شمسی در pandas معرفی بسته pandas-jalali | آموزش کار با تاریخ شمسی در pandas

راهنمای ویدیویی

IMAGE ALT TEXT HERE

ToDos:

  • add gregorian to Jalali Conversion
  • add Jalali to gregorian Conversion
  • add support for sampling
  • add date parser from other columns
  • add date parser from string

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

jalali_pandas-0.2.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

jalali_pandas-0.2.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file jalali_pandas-0.2.1.tar.gz.

File metadata

  • Download URL: jalali_pandas-0.2.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

File hashes

Hashes for jalali_pandas-0.2.1.tar.gz
Algorithm Hash digest
SHA256 87e9afa9297ebd4fdc580d89660fb84af5242e0d60bd94c50b31afa3aabb0216
MD5 a2dae09eaa71eb9644aa58440f7bd293
BLAKE2b-256 d6a65b65ca2071d4e0096b77098652488a476a8b665b8507d3e1b3288cfaa2b4

See more details on using hashes here.

File details

Details for the file jalali_pandas-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: jalali_pandas-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure

File hashes

Hashes for jalali_pandas-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40c85701d078fd5982cea2a555ba10ab33ae32c403350489978064994fcc0a19
MD5 c1a30d946d97baf1b4f9636c57f7849f
BLAKE2b-256 415f72999f19c7bfd28b7bccddb16796fa9a8b54cb45415fdbc98268bbd18385

See more details on using hashes here.

Supported by

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