Core¶
JalaliTimestamp - Scalar Jalali datetime type.
JalaliTimestamp ¶
A Jalali (Persian/Shamsi) calendar timestamp.
Similar to pandas.Timestamp but for the Jalali calendar system.
Attributes:
| Name | Type | Description |
|---|---|---|
year |
int
|
Jalali year. |
month |
int
|
Jalali month (1-12). |
day |
int
|
Jalali day (1-31). |
hour |
int
|
Hour (0-23). |
minute |
int
|
Minute (0-59). |
second |
int
|
Second (0-59). |
microsecond |
int
|
Microsecond (0-999999). |
nanosecond |
int
|
Nanosecond (0-999). |
tzinfo |
tzinfo | None
|
Timezone information. |
Examples:
>>> ts = JalaliTimestamp(1402, 6, 15)
>>> ts.year
1402
>>> ts.month
6
>>> ts.to_gregorian()
Timestamp('2023-09-06 00:00:00')
Source code in jalali_pandas/core/timestamp.py
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 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 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | |
is_year_start
property
¶
is_year_start: bool
Whether the date is the first day of the year (Nowruz).
__add__ ¶
__add__(other: timedelta | Timedelta) -> JalaliTimestamp
Add timedelta to timestamp.
Source code in jalali_pandas/core/timestamp.py
486 487 488 489 490 491 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality.
Source code in jalali_pandas/core/timestamp.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
__ge__ ¶
__ge__(other: JalaliTimestamp) -> bool
Greater than or equal comparison.
Source code in jalali_pandas/core/timestamp.py
549 550 551 552 553 | |
__gt__ ¶
__gt__(other: JalaliTimestamp) -> bool
Greater than comparison.
Source code in jalali_pandas/core/timestamp.py
543 544 545 546 547 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/core/timestamp.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
__init__ ¶
__init__(year: int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, nanosecond: int = 0, tzinfo: tzinfo | None = None) -> None
Initialize a JalaliTimestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). Defaults to 1. |
1
|
day
|
int
|
Jalali day. Defaults to 1. |
1
|
hour
|
int
|
Hour (0-23). Defaults to 0. |
0
|
minute
|
int
|
Minute (0-59). Defaults to 0. |
0
|
second
|
int
|
Second (0-59). Defaults to 0. |
0
|
microsecond
|
int
|
Microsecond (0-999999). Defaults to 0. |
0
|
nanosecond
|
int
|
Nanosecond (0-999). Defaults to 0. |
0
|
tzinfo
|
tzinfo | None
|
Timezone. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any component is out of valid range. |
Source code in jalali_pandas/core/timestamp.py
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 | |
__le__ ¶
__le__(other: JalaliTimestamp) -> bool
Less than or equal comparison.
Source code in jalali_pandas/core/timestamp.py
537 538 539 540 541 | |
__lt__ ¶
__lt__(other: JalaliTimestamp) -> bool
Less than comparison.
Source code in jalali_pandas/core/timestamp.py
531 532 533 534 535 | |
__ne__ ¶
__ne__(other: object) -> bool
Check inequality.
Source code in jalali_pandas/core/timestamp.py
527 528 529 | |
__radd__ ¶
__radd__(other: timedelta | Timedelta) -> JalaliTimestamp
Right add timedelta to timestamp.
Source code in jalali_pandas/core/timestamp.py
493 494 495 | |
__repr__ ¶
__repr__() -> str
Detailed string representation.
Source code in jalali_pandas/core/timestamp.py
574 575 576 577 | |
__str__ ¶
__str__() -> str
Human-readable string representation.
Source code in jalali_pandas/core/timestamp.py
579 580 581 | |
__sub__ ¶
__sub__(other: JalaliTimestamp | timedelta | Timedelta) -> JalaliTimestamp | pd.Timedelta
Subtract timedelta or another timestamp.
Source code in jalali_pandas/core/timestamp.py
497 498 499 500 501 502 503 504 505 506 | |
date ¶
date() -> JalaliTimestamp
Return date part only (time set to midnight).
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
New JalaliTimestamp at midnight. |
Source code in jalali_pandas/core/timestamp.py
635 636 637 638 639 640 641 | |
from_gregorian
classmethod
¶
from_gregorian(ts: Timestamp | datetime | str, tz: tzinfo | str | None = None) -> JalaliTimestamp
Create JalaliTimestamp from Gregorian datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts
|
Timestamp | datetime | str
|
Gregorian timestamp (pandas Timestamp, datetime, or string). |
required |
tz
|
tzinfo | str | None
|
Timezone to use. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Equivalent JalaliTimestamp. |
Source code in jalali_pandas/core/timestamp.py
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 | |
isoformat ¶
isoformat(sep: str = 'T') -> str
Return ISO 8601 formatted string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sep
|
str
|
Separator between date and time. Defaults to 'T'. |
'T'
|
Returns:
| Type | Description |
|---|---|
str
|
ISO formatted string. |
Source code in jalali_pandas/core/timestamp.py
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 | |
normalize ¶
normalize() -> JalaliTimestamp
Return timestamp with time set to midnight.
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
New JalaliTimestamp at midnight. |
Source code in jalali_pandas/core/timestamp.py
627 628 629 630 631 632 633 | |
now
classmethod
¶
now(tz: tzinfo | str | None = None) -> JalaliTimestamp
Get current JalaliTimestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
tzinfo | str | None
|
Timezone. Defaults to None (local time). |
None
|
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Current time as JalaliTimestamp. |
Source code in jalali_pandas/core/timestamp.py
344 345 346 347 348 349 350 351 352 353 354 | |
replace ¶
replace(year: int | None = None, month: int | None = None, day: int | None = None, hour: int | None = None, minute: int | None = None, second: int | None = None, microsecond: int | None = None, nanosecond: int | None = None, tzinfo: tzinfo | None | object = ...) -> JalaliTimestamp
Return timestamp with replaced components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int | None
|
New year (or None to keep current). |
None
|
month
|
int | None
|
New month (or None to keep current). |
None
|
day
|
int | None
|
New day (or None to keep current). |
None
|
hour
|
int | None
|
New hour (or None to keep current). |
None
|
minute
|
int | None
|
New minute (or None to keep current). |
None
|
second
|
int | None
|
New second (or None to keep current). |
None
|
microsecond
|
int | None
|
New microsecond (or None to keep current). |
None
|
nanosecond
|
int | None
|
New nanosecond (or None to keep current). |
None
|
tzinfo
|
tzinfo | None | object
|
New timezone (or ... to keep current). |
...
|
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
New JalaliTimestamp with replaced components. |
Source code in jalali_pandas/core/timestamp.py
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 | |
strftime ¶
strftime(fmt: str) -> str
Format timestamp as string.
Supports standard strftime codes adapted for Jalali calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fmt
|
str
|
Format string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string. |
Source code in jalali_pandas/core/timestamp.py
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 | |
strptime
classmethod
¶
strptime(date_string: str, fmt: str) -> JalaliTimestamp
Parse string to JalaliTimestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_string
|
str
|
Date string to parse. |
required |
fmt
|
str
|
Format string. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Parsed JalaliTimestamp. |
Source code in jalali_pandas/core/timestamp.py
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 | |
time ¶
time() -> time
Return time part as Python time object.
Returns:
| Type | Description |
|---|---|
time
|
Python time object. |
Source code in jalali_pandas/core/timestamp.py
643 644 645 646 647 648 649 650 651 652 653 654 655 | |
to_datetime64 ¶
to_datetime64() -> np.datetime64
Convert to numpy datetime64.
Returns:
| Type | Description |
|---|---|
datetime64
|
Equivalent numpy datetime64. |
Source code in jalali_pandas/core/timestamp.py
297 298 299 300 301 302 303 | |
to_gregorian ¶
to_gregorian() -> pd.Timestamp
Convert to pandas Timestamp (Gregorian).
Returns:
| Type | Description |
|---|---|
Timestamp
|
Equivalent pandas Timestamp in Gregorian calendar. |
Source code in jalali_pandas/core/timestamp.py
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 | |
to_pydatetime ¶
to_pydatetime() -> datetime
Convert to Python datetime (Gregorian).
Returns:
| Type | Description |
|---|---|
datetime
|
Equivalent Python datetime in Gregorian calendar. |
Source code in jalali_pandas/core/timestamp.py
289 290 291 292 293 294 295 | |
today
classmethod
¶
today() -> JalaliTimestamp
Get today's date as JalaliTimestamp (midnight).
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Today's date as JalaliTimestamp. |
Source code in jalali_pandas/core/timestamp.py
356 357 358 359 360 361 362 363 364 | |
tz_convert ¶
tz_convert(tz: tzinfo | str | None) -> JalaliTimestamp
Convert tz-aware timestamp to another timezone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
tzinfo | str | None
|
Target timezone. Can be a timezone object or string. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
New JalaliTimestamp in the target timezone. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If timestamp is tz-naive. |
Source code in jalali_pandas/core/timestamp.py
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | |
tz_localize ¶
tz_localize(tz: tzinfo | str | None, ambiguous: str = 'raise', nonexistent: str = 'raise') -> JalaliTimestamp
Localize tz-naive timestamp to a timezone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
tzinfo | str | None
|
Timezone to localize to. Can be a timezone object or string. |
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 |
|---|---|
JalaliTimestamp
|
New JalaliTimestamp with timezone. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If timestamp is already tz-aware. |
Source code in jalali_pandas/core/timestamp.py
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 | |
isna_jalali ¶
isna_jalali(value: object) -> bool
Check if a value is JalaliNaT or pandas NaT.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
Value to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if value is NaT. |
Source code in jalali_pandas/core/timestamp.py
930 931 932 933 934 935 936 937 938 939 | |
JalaliDatetimeDtype - ExtensionDtype for Jalali datetime.
JalaliDatetimeDtype ¶
Bases: ExtensionDtype
ExtensionDtype for Jalali datetime data.
This dtype represents Jalali (Persian/Shamsi) calendar datetimes and integrates with pandas' ExtensionArray system.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
String identifier for the dtype. |
|
type |
The scalar type for the array. |
|
na_value |
The missing value sentinel. |
Examples:
>>> dtype = JalaliDatetimeDtype()
>>> dtype.name
'jalali_datetime'
>>> pd.array([...], dtype='jalali_datetime')
Source code in jalali_pandas/core/dtypes.py
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 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality with another dtype.
Source code in jalali_pandas/core/dtypes.py
103 104 105 106 107 108 109 110 111 112 113 114 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/core/dtypes.py
99 100 101 | |
__init__ ¶
__init__(tz: str | None = None) -> None
Initialize JalaliDatetimeDtype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tz
|
str | None
|
Timezone string (e.g., 'Asia/Tehran'). Defaults to None. |
None
|
Source code in jalali_pandas/core/dtypes.py
39 40 41 42 43 44 45 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/core/dtypes.py
89 90 91 92 93 | |
__str__ ¶
__str__() -> str
String representation.
Source code in jalali_pandas/core/dtypes.py
95 96 97 | |
construct_array_type
classmethod
¶
construct_array_type() -> builtins.type[JalaliDatetimeArray]
Return the array type associated with this dtype.
Returns:
| Type | Description |
|---|---|
type[JalaliDatetimeArray]
|
JalaliDatetimeArray class. |
Source code in jalali_pandas/core/dtypes.py
52 53 54 55 56 57 58 59 60 61 | |
construct_from_string
classmethod
¶
construct_from_string(string: str) -> JalaliDatetimeDtype
Construct dtype from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
str
|
String representation of the dtype. |
required |
Returns:
| Type | Description |
|---|---|
JalaliDatetimeDtype
|
JalaliDatetimeDtype instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If string doesn't match expected format. |
Source code in jalali_pandas/core/dtypes.py
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 | |
JalaliDatetimeArray - ExtensionArray for Jalali datetime.
JalaliDatetimeArray ¶
Bases: ExtensionArray
ExtensionArray for Jalali datetime data.
This array stores Jalali timestamps and integrates with pandas' ExtensionArray system for seamless DataFrame/Series operations.
Attributes:
| Name | Type | Description |
|---|---|---|
dtype |
JalaliDatetimeDtype
|
The JalaliDatetimeDtype for this array. |
Examples:
>>> arr = JalaliDatetimeArray._from_sequence([
... JalaliTimestamp(1402, 1, 1),
... JalaliTimestamp(1402, 1, 2),
... ])
>>> arr[0]
JalaliTimestamp('1402-01-01T00:00:00')
Source code in jalali_pandas/core/arrays.py
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 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 | |
__eq__ ¶
__eq__(other: Any) -> Any
Element-wise equality comparison.
Source code in jalali_pandas/core/arrays.py
107 108 109 110 111 112 113 114 115 116 | |
__getitem__ ¶
__getitem__(key: int) -> JalaliTimestamp | NaTType
__getitem__(key: slice | Sequence[int] | NDArray[bool_]) -> JalaliDatetimeArray
__getitem__(key: Any) -> Any
Get item(s) from the array.
Source code in jalali_pandas/core/arrays.py
80 81 82 83 84 85 86 87 | |
__init__ ¶
__init__(data: ndarray, dtype: JalaliDatetimeDtype | None = None, copy: bool = False) -> None
Initialize JalaliDatetimeArray.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Array of JalaliTimestamp objects. |
required |
dtype
|
JalaliDatetimeDtype | None
|
JalaliDatetimeDtype instance. Defaults to None. |
None
|
copy
|
bool
|
Whether to copy the data. Defaults to False. |
False
|
Source code in jalali_pandas/core/arrays.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
__iter__ ¶
__iter__() -> Iterator[Any]
Iterate over the array.
Source code in jalali_pandas/core/arrays.py
103 104 105 | |
__len__ ¶
__len__() -> int
Return the length of the array.
Source code in jalali_pandas/core/arrays.py
68 69 70 | |
__ne__ ¶
__ne__(other: Any) -> Any
Element-wise inequality comparison.
Source code in jalali_pandas/core/arrays.py
118 119 120 121 122 123 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/core/arrays.py
268 269 270 271 272 273 | |
__setitem__ ¶
__setitem__(key: Any, value: Any) -> None
Set item(s) in the array.
Source code in jalali_pandas/core/arrays.py
89 90 91 92 93 94 95 96 97 98 99 100 101 | |
copy ¶
copy() -> JalaliDatetimeArray
Return a copy of the array.
Source code in jalali_pandas/core/arrays.py
247 248 249 | |
isna ¶
isna() -> npt.NDArray[np.bool_]
Return boolean array indicating NA values.
Source code in jalali_pandas/core/arrays.py
207 208 209 210 211 212 | |
strftime ¶
strftime(fmt: str) -> npt.NDArray[np.object_]
Format timestamps as strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fmt
|
str
|
Format string. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[object_]
|
Array of formatted strings. |
Source code in jalali_pandas/core/arrays.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
take ¶
take(indices: Sequence[int], *, allow_fill: bool = False, fill_value: Any = None) -> JalaliDatetimeArray
Take elements from the array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
Sequence[int]
|
Indices to take. |
required |
allow_fill
|
bool
|
Whether to allow fill values for -1 indices. |
False
|
fill_value
|
Any
|
Value to use for -1 indices. |
None
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeArray
|
JalaliDatetimeArray with taken elements. |
Source code in jalali_pandas/core/arrays.py
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 | |
to_gregorian ¶
to_gregorian() -> pd.DatetimeIndex
Convert to pandas DatetimeIndex (Gregorian).
Returns:
| Type | Description |
|---|---|
DatetimeIndex
|
DatetimeIndex with Gregorian timestamps. |
Source code in jalali_pandas/core/arrays.py
389 390 391 392 393 394 395 396 397 398 | |
JalaliDatetimeIndex - Index for Jalali datetime data.
JalaliDatetimeIndex ¶
Bases: Index
Index for Jalali datetime data.
A JalaliDatetimeIndex is an immutable array of Jalali timestamps, suitable for use as an index in pandas DataFrames and Series.
Examples:
>>> idx = JalaliDatetimeIndex(["1402-01-01", "1402-01-02", "1402-01-03"])
>>> idx
JalaliDatetimeIndex(['1402-01-01', '1402-01-02', '1402-01-03'],
dtype='jalali_datetime64[ns]', freq=None)
>>> idx.year
Index([1402, 1402, 1402], dtype='float64')
Source code in jalali_pandas/core/indexes.py
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 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 | |
__contains__ ¶
__contains__(key: Any) -> bool
Check if key is in the index.
Source code in jalali_pandas/core/indexes.py
174 175 176 177 178 179 180 | |
__eq__ ¶
__eq__(other: Any) -> Any
Element-wise equality comparison.
Source code in jalali_pandas/core/indexes.py
647 648 649 650 651 652 653 654 655 656 | |
__getitem__ ¶
__getitem__(key: Any) -> Any
Get item(s) from the index.
Source code in jalali_pandas/core/indexes.py
161 162 163 164 165 166 167 168 | |
__iter__ ¶
__iter__() -> Any
Iterate over the index.
Source code in jalali_pandas/core/indexes.py
170 171 172 | |
__len__ ¶
__len__() -> int
Return the length of the index.
Source code in jalali_pandas/core/indexes.py
157 158 159 | |
__ne__ ¶
__ne__(other: Any) -> Any
Element-wise inequality comparison.
Source code in jalali_pandas/core/indexes.py
658 659 660 661 662 663 | |
__new__ ¶
__new__(data: Sequence[Any] | JalaliDatetimeArray | JalaliDatetimeIndex | None = None, freq: str | JalaliOffset | None = None, tz: tzinfo | str | None = None, dtype: JalaliDatetimeDtype | None = None, copy: bool = False, name: Hashable = None) -> JalaliDatetimeIndex
Create a new JalaliDatetimeIndex.
Source code in jalali_pandas/core/indexes.py
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 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/core/indexes.py
182 183 184 185 186 187 188 189 190 | |
copy ¶
copy(name: Hashable = None, deep: bool = True) -> JalaliDatetimeIndex
Make a copy of this object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Hashable
|
Name for the new index. |
None
|
deep
|
bool
|
Whether to make a deep copy. |
True
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Copy of the index. |
Source code in jalali_pandas/core/indexes.py
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
difference ¶
difference(other: JalaliDatetimeIndex, sort: bool | None = True) -> JalaliDatetimeIndex
Return a new JalaliDatetimeIndex with elements not in other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
JalaliDatetimeIndex
|
Another JalaliDatetimeIndex. |
required |
sort
|
bool | None
|
Whether to sort the result. |
True
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Difference of the two indexes. |
Source code in jalali_pandas/core/indexes.py
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 | |
equals ¶
equals(other: object) -> bool
Determine if two Index objects are equal.
Source code in jalali_pandas/core/indexes.py
636 637 638 639 640 641 642 643 644 645 | |
get_loc ¶
get_loc(key: Any) -> int | slice | npt.NDArray[np.bool_]
Get integer location for requested label.
Supports: - JalaliTimestamp: exact match - String: "1402-06-15" for exact date - Partial string: "1402-06" for month, "1402" for year
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Any
|
Label to look up. |
required |
Returns:
| Type | Description |
|---|---|
int | slice | NDArray[bool_]
|
Integer location, slice, or boolean mask. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If key is not found. |
Source code in jalali_pandas/core/indexes.py
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 | |
intersection ¶
intersection(other: JalaliDatetimeIndex, sort: bool = False) -> JalaliDatetimeIndex
Form the intersection of two JalaliDatetimeIndex objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
JalaliDatetimeIndex
|
Another JalaliDatetimeIndex. |
required |
sort
|
bool
|
Whether to sort the result. |
False
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Intersection of the two indexes. |
Source code in jalali_pandas/core/indexes.py
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 | |
shift ¶
shift(periods: int = 1, freq: str | JalaliOffset | Timedelta | None = None) -> JalaliDatetimeIndex
Shift index by desired number of time frequency increments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
periods
|
int
|
Number of periods to shift. |
1
|
freq
|
str | JalaliOffset | Timedelta | None
|
Frequency to shift by. If None, uses the index's freq. |
None
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Shifted JalaliDatetimeIndex. |
Source code in jalali_pandas/core/indexes.py
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 | |
slice_locs ¶
slice_locs(start: str | JalaliTimestamp | None = None, end: str | JalaliTimestamp | None = None, step: int | None = None) -> tuple[int, int]
Compute slice locations for input labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
str | JalaliTimestamp | None
|
Start label. |
None
|
end
|
str | JalaliTimestamp | None
|
End label. |
None
|
step
|
int | None
|
Step size. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (start, end) integer locations. |
Source code in jalali_pandas/core/indexes.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 388 389 390 391 392 393 394 | |
snap ¶
snap(freq: str = 's') -> JalaliDatetimeIndex
Snap time stamps to nearest occurring frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency to snap to (e.g., 's' for second, 'min' for minute). |
's'
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Snapped JalaliDatetimeIndex. |
Source code in jalali_pandas/core/indexes.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
strftime ¶
strftime(fmt: str) -> Any
Format timestamps as strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fmt
|
str
|
Format string. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Index of formatted strings. |
Source code in jalali_pandas/core/indexes.py
268 269 270 271 272 273 274 275 276 277 | |
to_gregorian ¶
to_gregorian() -> pd.DatetimeIndex
Convert to pandas DatetimeIndex (Gregorian).
Returns:
| Type | Description |
|---|---|
DatetimeIndex
|
DatetimeIndex with Gregorian timestamps. |
Source code in jalali_pandas/core/indexes.py
260 261 262 263 264 265 266 | |
to_list ¶
to_list() -> list[JalaliTimestamp]
Return a list of the values.
Source code in jalali_pandas/core/indexes.py
689 690 691 | |
to_numpy ¶
to_numpy(dtype: Any = None, copy: bool = False, na_value: Any = None) -> npt.NDArray[Any]
Convert to numpy array.
Source code in jalali_pandas/core/indexes.py
678 679 680 681 682 683 684 685 686 687 | |
tolist ¶
tolist() -> list[JalaliTimestamp]
Return a list of the values.
Source code in jalali_pandas/core/indexes.py
693 694 695 | |
union ¶
union(other: JalaliDatetimeIndex, sort: bool | None = None) -> JalaliDatetimeIndex
Form the union of two JalaliDatetimeIndex objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
JalaliDatetimeIndex
|
Another JalaliDatetimeIndex. |
required |
sort
|
bool | None
|
Whether to sort the result. |
None
|
Returns:
| Type | Description |
|---|---|
JalaliDatetimeIndex
|
Union of the two indexes. |
Source code in jalali_pandas/core/indexes.py
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 | |
Jalali calendar rules and utilities.
day_of_year ¶
day_of_year(year: int, month: int, day: int) -> int
Get the day of year (1-366).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Day of year (1-366). |
Source code in jalali_pandas/core/calendar.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
days_in_month ¶
days_in_month(year: int, month: int) -> int
Get the number of days in a Jalali month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of days in the month. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If month is not in range 1-12. |
Source code in jalali_pandas/core/calendar.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
days_in_month_vectorized ¶
days_in_month_vectorized(years: NDArray[int64], months: NDArray[int64]) -> npt.NDArray[np.int64]
Vectorized calculation of days in month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
NDArray[int64]
|
Array of Jalali years. |
required |
months
|
NDArray[int64]
|
Array of Jalali months (1-12). |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int64]
|
Array of days in each month. |
Source code in jalali_pandas/core/calendar.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
days_in_year ¶
days_in_year(year: int) -> int
Get the number of days in a Jalali year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
Returns:
| Type | Description |
|---|---|
int
|
365 for normal years, 366 for leap years. |
Source code in jalali_pandas/core/calendar.py
106 107 108 109 110 111 112 113 114 115 | |
is_leap_year ¶
is_leap_year(year: int) -> bool
Check if a Jalali year is a leap year.
Uses the 33-year cycle algorithm used by jdatetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the year is a leap year, False otherwise. |
Source code in jalali_pandas/core/calendar.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
is_leap_year_vectorized ¶
is_leap_year_vectorized(years: NDArray[int64]) -> npt.NDArray[np.bool_]
Vectorized check for leap years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
NDArray[int64]
|
Array of Jalali years. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[bool_]
|
Boolean array indicating leap years. |
Source code in jalali_pandas/core/calendar.py
93 94 95 96 97 98 99 100 101 102 103 | |
jalali_to_jdn ¶
jalali_to_jdn(year: int, month: int, day: int) -> int
Convert Jalali date to Julian Day Number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Julian Day Number. |
Source code in jalali_pandas/core/calendar.py
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 | |
jdn_to_jalali ¶
jdn_to_jalali(jdn: int) -> tuple[int, int, int]
Convert Julian Day Number to Jalali date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jdn
|
int
|
Julian Day Number. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (year, month, day). |
Source code in jalali_pandas/core/calendar.py
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 | |
quarter_of_month ¶
quarter_of_month(month: int) -> int
Get the quarter for a given month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
month
|
int
|
Jalali month (1-12). |
required |
Returns:
| Type | Description |
|---|---|
int
|
Quarter number (1-4). |
Source code in jalali_pandas/core/calendar.py
163 164 165 166 167 168 169 170 171 172 | |
validate_jalali_date ¶
validate_jalali_date(year: int, month: int, day: int) -> bool
Validate a Jalali date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the date is valid. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the date is invalid. |
Source code in jalali_pandas/core/calendar.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
week_of_year ¶
week_of_year(year: int, month: int, day: int) -> int
Get the week number of the year.
Week 1 is the first week containing at least 4 days. Weeks start on Saturday (Jalali calendar convention).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Week number (1-53). |
Source code in jalali_pandas/core/calendar.py
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 | |
weekday_of_jalali ¶
weekday_of_jalali(year: int, month: int, day: int) -> int
Get the weekday of a Jalali date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Weekday (0=Saturday, 6=Friday). |
Source code in jalali_pandas/core/calendar.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
Vectorized conversion utilities for Jalali-Gregorian date conversions.
This module provides optimized conversion functions using NumPy for efficient batch processing of date conversions.
datetime64_to_jalali ¶
datetime64_to_jalali(dt: NDArray[datetime64]) -> tuple[NDArray[np.int64], NDArray[np.int64], NDArray[np.int64]]
Convert numpy datetime64 array to Jalali date components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
NDArray[datetime64]
|
Array of numpy datetime64 values. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray[int64], NDArray[int64], NDArray[int64]]
|
Tuple of (jalali_year, jalali_month, jalali_day) arrays. |
Source code in jalali_pandas/core/conversion.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
gregorian_to_jalali_scalar
cached
¶
gregorian_to_jalali_scalar(year: int, month: int, day: int) -> tuple[int, int, int]
Convert a single Gregorian date to Jalali.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Gregorian year. |
required |
month
|
int
|
Gregorian month (1-12). |
required |
day
|
int
|
Gregorian day. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (jalali_year, jalali_month, jalali_day). |
Source code in jalali_pandas/core/conversion.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
gregorian_to_jalali_vectorized ¶
gregorian_to_jalali_vectorized(year: NDArray[int64], month: NDArray[int64], day: NDArray[int64], *, use_lookup: bool = True) -> tuple[NDArray[np.int64], NDArray[np.int64], NDArray[np.int64]]
Convert arrays of Gregorian dates to Jalali.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
NDArray[int64]
|
Array of Gregorian years. |
required |
month
|
NDArray[int64]
|
Array of Gregorian months (1-12). |
required |
day
|
NDArray[int64]
|
Array of Gregorian days. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray[int64], NDArray[int64], NDArray[int64]]
|
Tuple of (jalali_year, jalali_month, jalali_day) arrays. |
Source code in jalali_pandas/core/conversion.py
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 | |
jalali_to_datetime64 ¶
jalali_to_datetime64(year: NDArray[int64], month: NDArray[int64], day: NDArray[int64], hour: NDArray[int64] | None = None, minute: NDArray[int64] | None = None, second: NDArray[int64] | None = None, microsecond: NDArray[int64] | None = None, nanosecond: NDArray[int64] | None = None) -> NDArray[np.datetime64]
Convert Jalali date components to numpy datetime64 array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
NDArray[int64]
|
Array of Jalali years. |
required |
month
|
NDArray[int64]
|
Array of Jalali months (1-12). |
required |
day
|
NDArray[int64]
|
Array of Jalali days. |
required |
hour
|
NDArray[int64] | None
|
Optional array of hours. |
None
|
minute
|
NDArray[int64] | None
|
Optional array of minutes. |
None
|
second
|
NDArray[int64] | None
|
Optional array of seconds. |
None
|
microsecond
|
NDArray[int64] | None
|
Optional array of microseconds. |
None
|
nanosecond
|
NDArray[int64] | None
|
Optional array of nanoseconds. |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[datetime64]
|
Array of numpy datetime64 values. |
Source code in jalali_pandas/core/conversion.py
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 | |
jalali_to_gregorian_scalar
cached
¶
jalali_to_gregorian_scalar(year: int, month: int, day: int) -> tuple[int, int, int]
Convert a single Jalali date to Gregorian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Jalali year. |
required |
month
|
int
|
Jalali month (1-12). |
required |
day
|
int
|
Jalali day. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (gregorian_year, gregorian_month, gregorian_day). |
Source code in jalali_pandas/core/conversion.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
jalali_to_gregorian_vectorized ¶
jalali_to_gregorian_vectorized(year: NDArray[int64], month: NDArray[int64], day: NDArray[int64], *, use_lookup: bool = True) -> tuple[NDArray[np.int64], NDArray[np.int64], NDArray[np.int64]]
Convert arrays of Jalali dates to Gregorian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
NDArray[int64]
|
Array of Jalali years. |
required |
month
|
NDArray[int64]
|
Array of Jalali months (1-12). |
required |
day
|
NDArray[int64]
|
Array of Jalali days. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray[int64], NDArray[int64], NDArray[int64]]
|
Tuple of (gregorian_year, gregorian_month, gregorian_day) arrays. |
Source code in jalali_pandas/core/conversion.py
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 | |