Accessors¶
Enhanced Series accessor for Jalali datetime operations.
JalaliSeriesAccessor ¶
Enhanced accessor for Jalali datetime operations on pandas Series.
Provides properties and methods for working with Jalali (Persian/Shamsi) dates in pandas Series.
Attributes:
| Name | Type | Description |
|---|---|---|
year |
Series
|
Jalali year component. |
month |
Series
|
Jalali month component (1-12). |
day |
Series
|
Jalali day component. |
hour |
Series
|
Hour component (0-23). |
minute |
Series
|
Minute component (0-59). |
second |
Series
|
Second component (0-59). |
microsecond |
Series
|
Microsecond component. |
nanosecond |
Series
|
Nanosecond component. |
quarter |
Series
|
Quarter of the year (1-4). |
weekday |
Series
|
Day of week (0=Saturday, 6=Friday). |
dayofweek |
Series
|
Alias for weekday. |
dayofyear |
Series
|
Day of year (1-366). |
daysinmonth |
Series
|
Number of days in the month. |
week |
Series
|
Week of year. |
weekofyear |
Series
|
Alias for week. |
is_leap_year |
Series
|
Whether the year is a leap year. |
is_month_start |
Series
|
Whether the date is the first day of the month. |
is_month_end |
Series
|
Whether the date is the last day of the month. |
is_quarter_start |
Series
|
Whether the date is the first day of a quarter. |
is_quarter_end |
Series
|
Whether the date is the last day of a quarter. |
is_year_start |
Series
|
Whether the date is the first day of the year. |
is_year_end |
Series
|
Whether the date is the last day of the year. |
date |
Series
|
Date part (time set to midnight). |
time |
Series
|
Time part as Python time objects. |
Examples:
>>> import pandas as pd
>>> import jalali_pandas
>>> s = pd.Series(pd.date_range("2023-03-21", periods=5))
>>> s.jalali.to_jalali()
>>> s.jalali.year
>>> s.jalali.month_name()
Source code in jalali_pandas/accessors/series.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
is_quarter_start
property
¶
is_quarter_start: Series
Check if the date is the first day of a quarter.
is_year_start
property
¶
is_year_start: Series
Check if the date is the first day of the year (Nowruz).
__init__ ¶
__init__(pandas_obj: Series) -> None
Initialize the accessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pandas_obj
|
Series
|
A pandas Series containing datetime data. |
required |
Source code in jalali_pandas/accessors/series.py
69 70 71 72 73 74 75 | |
ceil ¶
ceil(freq: str) -> pd.Series
Ceil dates to specified frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency string. Supported: 'D' (day), 'h' (hour), 'min' (minute), 's' (second). |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Series with ceiled dates. |
Source code in jalali_pandas/accessors/series.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
day_name ¶
day_name(locale: Literal['fa', 'en'] = 'en') -> pd.Series
Get day names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale
|
Literal['fa', 'en']
|
Language for day names. 'fa' for Persian, 'en' for English. Defaults to 'en'. |
'en'
|
Returns:
| Type | Description |
|---|---|
Series
|
Series of day names. |
Source code in jalali_pandas/accessors/series.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
floor ¶
floor(freq: str) -> pd.Series
Floor dates to specified frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency string. Supported: 'D' (day), 'h' (hour), 'min' (minute), 's' (second). |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Series with floored dates. |
Source code in jalali_pandas/accessors/series.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
month_name ¶
month_name(locale: Literal['fa', 'en'] = 'en') -> pd.Series
Get month names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale
|
Literal['fa', 'en']
|
Language for month names. 'fa' for Persian, 'en' for English. Defaults to 'en'. |
'en'
|
Returns:
| Type | Description |
|---|---|
Series
|
Series of month names. |
Source code in jalali_pandas/accessors/series.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
normalize ¶
normalize() -> pd.Series
Normalize dates to midnight.
Returns:
| Type | Description |
|---|---|
Series
|
Series with time components set to zero. |
Source code in jalali_pandas/accessors/series.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
parse_jalali ¶
parse_jalali(format: str = '%Y-%m-%d') -> pd.Series
Parse string dates to jdatetime objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
strftime format string. Defaults to "%Y-%m-%d". |
'%Y-%m-%d'
|
Returns:
| Type | Description |
|---|---|
Series
|
Series of jdatetime objects. |
Source code in jalali_pandas/accessors/series.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
round ¶
round(freq: str) -> pd.Series
Round dates to specified frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency string. Supported: 'D' (day), 'h' (hour), 'min' (minute), 's' (second). |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Series with rounded dates. |
Source code in jalali_pandas/accessors/series.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
strftime ¶
strftime(date_format: str) -> pd.Series
Format dates as strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_format
|
str
|
strftime format string. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Series of formatted strings. |
Source code in jalali_pandas/accessors/series.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
to_gregorian ¶
to_gregorian() -> pd.Series
Convert Jalali datetime to Gregorian datetime.
Returns:
| Type | Description |
|---|---|
Series
|
Series of Python datetime objects. |
Source code in jalali_pandas/accessors/series.py
133 134 135 136 137 138 139 140 141 142 143 | |
to_jalali ¶
to_jalali() -> pd.Series
Convert Gregorian datetime to Jalali datetime.
Returns:
| Type | Description |
|---|---|
Series
|
Series of jdatetime objects. |
Source code in jalali_pandas/accessors/series.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
tz_convert ¶
tz_convert(tz: tzinfo | str | None) -> pd.Series
Convert tz-aware dates to another timezone.
This converts the jdatetime objects to Gregorian, converts timezone, and returns the converted Gregorian datetimes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
tzinfo | str | None
|
Target timezone. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Series of timezone-converted Gregorian datetimes. |
Source code in jalali_pandas/accessors/series.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
tz_localize ¶
tz_localize(tz: tzinfo | str | None, ambiguous: str = 'raise', nonexistent: str = 'raise') -> pd.Series
Localize tz-naive dates to a timezone.
This converts the jdatetime objects to Gregorian, localizes them, and returns the localized Gregorian datetimes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
tzinfo | str | None
|
Timezone to localize to. |
required |
ambiguous
|
str
|
How to handle ambiguous times. Defaults to 'raise'. |
'raise'
|
nonexistent
|
str
|
How to handle nonexistent times. Defaults to 'raise'. |
'raise'
|
Returns:
| Type | Description |
|---|---|
Series
|
Series of timezone-aware Gregorian datetimes. |
Source code in jalali_pandas/accessors/series.py
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
Enhanced DataFrame accessor for Jalali datetime operations.
JalaliDataFrameAccessor ¶
Enhanced accessor for Jalali datetime operations on pandas DataFrames.
Provides methods for working with Jalali (Persian/Shamsi) dates in pandas DataFrames, including groupby, resample, and column conversion.
Attributes:
| Name | Type | Description |
|---|---|---|
jdate |
str
|
Name of the detected Jalali date column. |
columns |
Index[Any]
|
DataFrame columns. |
Examples:
>>> import pandas as pd
>>> import jalali_pandas
>>> df = pd.DataFrame({
... 'date': pd.date_range('2023-03-21', periods=5),
... 'value': [1, 2, 3, 4, 5]
... })
>>> df['jdate'] = df['date'].jalali.to_jalali()
>>> df.jalali.groupby('month').sum()
Source code in jalali_pandas/accessors/dataframe.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
__init__ ¶
__init__(pandas_obj: DataFrame) -> None
Initialize the accessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pandas_obj
|
DataFrame
|
A pandas DataFrame containing Jalali datetime data. |
required |
Source code in jalali_pandas/accessors/dataframe.py
51 52 53 54 55 56 57 58 59 60 | |
convert_columns ¶
convert_columns(columns: list[str] | str, to_jalali: bool = True, format: str = '%Y-%m-%d') -> pd.DataFrame
Convert date columns between Jalali and Gregorian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
list[str] | str
|
Column name(s) to convert. |
required |
to_jalali
|
bool
|
If True, convert Gregorian to Jalali. If False, convert Jalali to Gregorian. Defaults to True. |
True
|
format
|
str
|
Format string for parsing string dates. Defaults to "%Y-%m-%d". |
'%Y-%m-%d'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with converted columns. |
Examples:
>>> df.jalali.convert_columns('date', to_jalali=True)
>>> df.jalali.convert_columns(['date1', 'date2'], to_jalali=False)
Source code in jalali_pandas/accessors/dataframe.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
filter_by_date_range ¶
filter_by_date_range(start: str | date | None = None, end: str | date | None = None) -> pd.DataFrame
Filter DataFrame by Jalali date range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
str | date | None
|
Start date (inclusive). Can be string 'YYYY-MM-DD' or jdatetime. |
None
|
end
|
str | date | None
|
End date (inclusive). Can be string 'YYYY-MM-DD' or jdatetime. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered DataFrame. |
Source code in jalali_pandas/accessors/dataframe.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
filter_by_month ¶
filter_by_month(month: int | list[int]) -> pd.DataFrame
Filter DataFrame by Jalali month(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
month
|
int | list[int]
|
Month or list of months to filter by (1-12). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered DataFrame. |
Source code in jalali_pandas/accessors/dataframe.py
334 335 336 337 338 339 340 341 342 343 344 345 | |
filter_by_quarter ¶
filter_by_quarter(quarter: int | list[int]) -> pd.DataFrame
Filter DataFrame by Jalali quarter(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quarter
|
int | list[int]
|
Quarter or list of quarters to filter by (1-4). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered DataFrame. |
Source code in jalali_pandas/accessors/dataframe.py
347 348 349 350 351 352 353 354 355 356 357 358 | |
filter_by_year ¶
filter_by_year(year: int | list[int]) -> pd.DataFrame
Filter DataFrame by Jalali year(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int | list[int]
|
Year or list of years to filter by. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered DataFrame. |
Source code in jalali_pandas/accessors/dataframe.py
321 322 323 324 325 326 327 328 329 330 331 332 | |
groupby ¶
groupby(grouper: str = 'md') -> DataFrameGroupByT
Group by Jalali date components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grouper
|
str
|
Grouping key. Options: - 'year': Group by year - 'month': Group by month - 'day': Group by day - 'week': Group by week number - 'dayofweek': Group by day of week - 'dayofmonth': Group by day of month (alias for 'day') - 'quarter': Group by quarter - 'dayofyear': Group by day of year - 'ym': Group by year and month - 'yq': Group by year and quarter - 'ymd': Group by year, month, and day - 'md': Group by month and day (default) |
'md'
|
Returns:
| Type | Description |
|---|---|
DataFrameGroupByT
|
DataFrameGroupBy object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If grouper is not a valid option. |
Source code in jalali_pandas/accessors/dataframe.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
resample ¶
resample(resample_type: str) -> pd.DataFrame
Resample by Jalali frequency.
Groups the DataFrame by Jalali calendar periods and aggregates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resample_type
|
str
|
The resample frequency. Options: - 'month': Group by Jalali month - 'quarter': Group by Jalali quarter - 'year': Group by Jalali year - 'week': Group by Jalali week |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregated values grouped by the specified period. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If resample_type is not valid. |
Examples:
>>> df.jalali.resample('month')
>>> df.jalali.resample('quarter')
Source code in jalali_pandas/accessors/dataframe.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
set_date_column ¶
set_date_column(column: str) -> JalaliDataFrameAccessor
Set the Jalali date column to use for operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
Name of the column containing Jalali dates. |
required |
Returns:
| Type | Description |
|---|---|
JalaliDataFrameAccessor
|
Self for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If column doesn't exist or doesn't contain jdatetime. |
Source code in jalali_pandas/accessors/dataframe.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
to_period ¶
to_period(freq: str = 'M') -> pd.DataFrame
Convert Jalali dates to period representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency for period. Options: - 'Y': Year - 'Q': Quarter - 'M': Month (default) - 'W': Week - 'D': Day |
'M'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with period column added. |
Source code in jalali_pandas/accessors/dataframe.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
Legacy accessors¶
Handle Jalali dates in pandas DataFrames.
JalaliDataframeAccessor ¶
Accessor methods on pandas DataFrames to handle Jalali dates.
Source code in jalali_pandas/df_handler.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
__init__ ¶
__init__(pandas_obj: DataFrame) -> None
Initialize the accessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pandas_obj
|
DataFrame
|
A pandas DataFrame containing Jalali datetime data. |
required |
Source code in jalali_pandas/df_handler.py
25 26 27 28 29 30 31 32 33 34 | |
groupby ¶
groupby(grouper: str = 'md') -> DataFrameGroupByT
Group by Jalali date components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grouper
|
str
|
Grouping key. Options: year, month, day, week, dayofweek, dayofmonth, ym, yq, ymd, md. Defaults to 'md'. |
'md'
|
Returns:
| Type | Description |
|---|---|
DataFrameGroupByT
|
DataFrameGroupBy object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If grouper is not a valid option. |
Source code in jalali_pandas/df_handler.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
resample ¶
resample(resample_type: str) -> pd.DataFrame
Resample by Jalali frequency.
Groups the DataFrame by Jalali calendar periods and aggregates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resample_type
|
str
|
The resample frequency. Options: - 'month': Group by Jalali month - 'quarter': Group by Jalali quarter - 'year': Group by Jalali year |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregated values grouped by the specified period. |
Examples:
>>> df.jalali.resample('month')
>>> df.jalali.resample('quarter')
Source code in jalali_pandas/df_handler.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
Handle Jalali dates in pandas series.
JalaliSerieAccessor ¶
Accessor methods on pandas series to handle Jalali dates.
Source code in jalali_pandas/serie_handler.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
day
property
¶
day: Series[Any]
get Jalali day
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali day |
hour
property
¶
hour: Series[Any]
get Jalali hour
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali hour |
minute
property
¶
minute: Series[Any]
get Jalali minute
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali minute |
month
property
¶
month: Series[Any]
get Jalali
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali month |
quarter
property
¶
quarter: Series[Any]
Get Jalali quarter.
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali quarter (1-4). |
second
property
¶
second: Series[Any]
get Jalali second
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali second |
weekday
property
¶
weekday: Series[Any]
get Jalali weekday
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali weekday |
weeknumber
property
¶
weeknumber: Series[Any]
get Jalali day of year
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali day of year |
year
property
¶
year: Series[Any]
get Jalali year
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: Jalali year |
__init__ ¶
__init__(pandas_obj: Series[Any]) -> None
Initialize the accessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pandas_obj
|
Series[Any]
|
A pandas Series containing datetime data. |
required |
Source code in jalali_pandas/serie_handler.py
14 15 16 17 18 19 20 | |
parse_jalali ¶
parse_jalali(format: str = '%Y-%m-%d') -> pd.Series[Any]
[summary]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
like gregorian datetime format. Defaults to "%Y-%m-%d". |
'%Y-%m-%d'
|
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: pd.Series of jalali datetime. |
Source code in jalali_pandas/serie_handler.py
52 53 54 55 56 57 58 59 60 61 62 63 | |
to_gregorian ¶
to_gregorian() -> pd.Series[Any]
convert jalali datetime to python default datetime.
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: pd.Series of python datetime. |
Source code in jalali_pandas/serie_handler.py
42 43 44 45 46 47 48 49 | |
to_jalali ¶
to_jalali() -> pd.Series[Any]
convert python datetime to jalali datetime.
Returns:
| Type | Description |
|---|---|
Series[Any]
|
pd.Series: pd.Series of jalali datetime. |
Source code in jalali_pandas/serie_handler.py
31 32 33 34 35 36 37 38 39 40 | |