Offsets¶
Jalali calendar frequency offsets.
JalaliMonthBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali month.
Source code in jalali_pandas/offsets/month.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add months to timestamp, landing on month start.
Source code in jalali_pandas/offsets/month.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract months from timestamp.
Source code in jalali_pandas/offsets/month.py
43 44 45 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on month start.
Source code in jalali_pandas/offsets/month.py
69 70 71 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous month start.
Source code in jalali_pandas/offsets/month.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next month start if not already on one.
Source code in jalali_pandas/offsets/month.py
47 48 49 50 51 | |
JalaliMonthEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali month.
Source code in jalali_pandas/offsets/month.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add months to timestamp, landing on month end.
Source code in jalali_pandas/offsets/month.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract months from timestamp.
Source code in jalali_pandas/offsets/month.py
104 105 106 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on month end.
Source code in jalali_pandas/offsets/month.py
140 141 142 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous month end.
Source code in jalali_pandas/offsets/month.py
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 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next month end if not already on one.
Source code in jalali_pandas/offsets/month.py
108 109 110 111 112 | |
JalaliOffset ¶
Bases: ABC
Abstract base class for Jalali calendar-aware offsets.
This class provides the foundation for implementing calendar-aware date offsets that respect Jalali calendar rules.
Attributes:
| Name | Type | Description |
|---|---|---|
n |
int
|
Number of periods. |
normalize |
bool
|
Whether to normalize to midnight. |
Source code in jalali_pandas/offsets/base.py
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 | |
__add__
abstractmethod
¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add offset to a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
84 85 86 87 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality.
Source code in jalali_pandas/offsets/base.py
60 61 62 63 64 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/offsets/base.py
66 67 68 | |
__init__ ¶
__init__(n: int = 1, normalize: bool = False) -> None
Initialize JalaliOffset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of periods. Defaults to 1. |
1
|
normalize
|
bool
|
Whether to normalize to midnight. Defaults to False. |
False
|
Source code in jalali_pandas/offsets/base.py
26 27 28 29 30 31 32 33 34 | |
__mul__ ¶
__mul__(other: int) -> JalaliOffset
Multiply offset by integer.
Source code in jalali_pandas/offsets/base.py
74 75 76 77 78 | |
__neg__ ¶
__neg__() -> JalaliOffset
Return negated offset.
Source code in jalali_pandas/offsets/base.py
70 71 72 | |
__radd__ ¶
__radd__(other: JalaliTimestamp) -> JalaliTimestamp
Right add offset to a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
89 90 91 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/offsets/base.py
56 57 58 | |
__rmul__ ¶
__rmul__(other: int) -> JalaliOffset
Right multiply offset by integer.
Source code in jalali_pandas/offsets/base.py
80 81 82 | |
__sub__
abstractmethod
¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract offset from a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
93 94 95 96 | |
is_on_offset
abstractmethod
¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on offset boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if on offset boundary. |
Source code in jalali_pandas/offsets/base.py
122 123 124 125 126 127 128 129 130 131 132 | |
rollback
abstractmethod
¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous valid date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to roll back. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Rolled back JalaliTimestamp. |
Source code in jalali_pandas/offsets/base.py
110 111 112 113 114 115 116 117 118 119 120 | |
rollforward
abstractmethod
¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next valid date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to roll forward. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Rolled forward JalaliTimestamp. |
Source code in jalali_pandas/offsets/base.py
98 99 100 101 102 103 104 105 106 107 108 | |
JalaliQuarterBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali quarter.
Source code in jalali_pandas/offsets/quarter.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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add quarters to timestamp, landing on quarter start.
Source code in jalali_pandas/offsets/quarter.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 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract quarters from timestamp.
Source code in jalali_pandas/offsets/quarter.py
52 53 54 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on quarter start.
Source code in jalali_pandas/offsets/quarter.py
80 81 82 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to current quarter start.
Source code in jalali_pandas/offsets/quarter.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next quarter start if not already on one.
Source code in jalali_pandas/offsets/quarter.py
56 57 58 59 60 | |
JalaliQuarterEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali quarter.
Source code in jalali_pandas/offsets/quarter.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add quarters to timestamp, landing on quarter end.
Source code in jalali_pandas/offsets/quarter.py
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 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract quarters from timestamp.
Source code in jalali_pandas/offsets/quarter.py
119 120 121 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on quarter end.
Source code in jalali_pandas/offsets/quarter.py
156 157 158 159 160 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous quarter end.
Source code in jalali_pandas/offsets/quarter.py
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 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next quarter end if not already on one.
Source code in jalali_pandas/offsets/quarter.py
123 124 125 126 127 | |
JalaliWeek ¶
Bases: JalaliOffset
Offset to a specific day of the Jalali week.
The Jalali week starts on Saturday (weekday=0) and ends on Friday (weekday=6).
Attributes:
| Name | Type | Description |
|---|---|---|
weekday |
int
|
The target weekday (0=Saturday, 6=Friday). Defaults to 0 (Saturday). |
Source code in jalali_pandas/offsets/week.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add weeks to timestamp, landing on target weekday.
Source code in jalali_pandas/offsets/week.py
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 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality.
Source code in jalali_pandas/offsets/week.py
65 66 67 68 69 70 71 72 73 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/offsets/week.py
75 76 77 | |
__init__ ¶
__init__(n: int = 1, normalize: bool = False, weekday: int = SATURDAY) -> None
Initialize JalaliWeek offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of weeks. Defaults to 1. |
1
|
normalize
|
bool
|
Whether to normalize to midnight. Defaults to False. |
False
|
weekday
|
int
|
Target weekday (0=Saturday, 6=Friday). Defaults to 0 (Saturday). |
SATURDAY
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If weekday is not in range 0-6. |
Source code in jalali_pandas/offsets/week.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
__mul__ ¶
__mul__(other: int) -> JalaliWeek
Multiply offset by integer.
Source code in jalali_pandas/offsets/week.py
83 84 85 86 87 88 89 | |
__neg__ ¶
__neg__() -> JalaliWeek
Return negated offset.
Source code in jalali_pandas/offsets/week.py
79 80 81 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/offsets/week.py
61 62 63 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract weeks from timestamp.
Source code in jalali_pandas/offsets/week.py
136 137 138 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on target weekday.
Source code in jalali_pandas/offsets/week.py
178 179 180 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous target weekday.
Source code in jalali_pandas/offsets/week.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next target weekday if not already on one.
Source code in jalali_pandas/offsets/week.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
JalaliYearBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali year (Nowruz).
Source code in jalali_pandas/offsets/year.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add years to timestamp, landing on year start (Nowruz).
Source code in jalali_pandas/offsets/year.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract years from timestamp.
Source code in jalali_pandas/offsets/year.py
40 41 42 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on year start (Nowruz - 1 Farvardin).
Source code in jalali_pandas/offsets/year.py
67 68 69 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to current year start.
Source code in jalali_pandas/offsets/year.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next year start if not already on one.
Source code in jalali_pandas/offsets/year.py
44 45 46 47 48 | |
JalaliYearEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali year.
Source code in jalali_pandas/offsets/year.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add years to timestamp, landing on year end.
Source code in jalali_pandas/offsets/year.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract years from timestamp.
Source code in jalali_pandas/offsets/year.py
100 101 102 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on year end (last day of Esfand).
Source code in jalali_pandas/offsets/year.py
131 132 133 134 135 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous year end.
Source code in jalali_pandas/offsets/year.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next year end if not already on one.
Source code in jalali_pandas/offsets/year.py
104 105 106 107 108 | |
get_jalali_alias ¶
get_jalali_alias(offset_class: type[JalaliOffset]) -> str | None
Get the frequency alias for an offset class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset_class
|
type[JalaliOffset]
|
The offset class. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The frequency alias, or None if not registered. |
Source code in jalali_pandas/offsets/aliases.py
46 47 48 49 50 51 52 53 54 55 | |
get_jalali_offset ¶
get_jalali_offset(alias: str) -> type[JalaliOffset] | None
Get the offset class for a frequency alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The frequency alias string. |
required |
Returns:
| Type | Description |
|---|---|
type[JalaliOffset] | None
|
The offset class, or None if not found. |
Source code in jalali_pandas/offsets/aliases.py
34 35 36 37 38 39 40 41 42 43 | |
list_jalali_aliases ¶
list_jalali_aliases() -> dict[str, str]
List all registered Jalali frequency aliases.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping aliases to offset class names. |
Source code in jalali_pandas/offsets/aliases.py
97 98 99 100 101 102 103 | |
parse_jalali_frequency ¶
parse_jalali_frequency(freq_str: str) -> JalaliOffset
Parse a frequency string into a Jalali offset instance.
Supports formats like: - "JME" -> JalaliMonthEnd(n=1) - "2JME" -> JalaliMonthEnd(n=2) - "-1JQS" -> JalaliQuarterBegin(n=-1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq_str
|
str
|
The frequency string to parse. |
required |
Returns:
| Type | Description |
|---|---|
JalaliOffset
|
A Jalali offset instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the frequency string is not recognized. |
Source code in jalali_pandas/offsets/aliases.py
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 | |
register_jalali_alias ¶
register_jalali_alias(alias: str, offset_class: type[JalaliOffset]) -> None
Register a frequency alias for a Jalali offset class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The frequency alias string (e.g., "JME", "JQS"). |
required |
offset_class
|
type[JalaliOffset]
|
The offset class to register. |
required |
Source code in jalali_pandas/offsets/aliases.py
23 24 25 26 27 28 29 30 31 | |
Frequency alias registration for Jalali offsets.
This module provides frequency alias registration and parsing for Jalali calendar offsets, enabling string-based frequency specifications like "JME", "2JQE", etc.
get_jalali_alias ¶
get_jalali_alias(offset_class: type[JalaliOffset]) -> str | None
Get the frequency alias for an offset class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset_class
|
type[JalaliOffset]
|
The offset class. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The frequency alias, or None if not registered. |
Source code in jalali_pandas/offsets/aliases.py
46 47 48 49 50 51 52 53 54 55 | |
get_jalali_offset ¶
get_jalali_offset(alias: str) -> type[JalaliOffset] | None
Get the offset class for a frequency alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The frequency alias string. |
required |
Returns:
| Type | Description |
|---|---|
type[JalaliOffset] | None
|
The offset class, or None if not found. |
Source code in jalali_pandas/offsets/aliases.py
34 35 36 37 38 39 40 41 42 43 | |
list_jalali_aliases ¶
list_jalali_aliases() -> dict[str, str]
List all registered Jalali frequency aliases.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping aliases to offset class names. |
Source code in jalali_pandas/offsets/aliases.py
97 98 99 100 101 102 103 | |
parse_jalali_frequency ¶
parse_jalali_frequency(freq_str: str) -> JalaliOffset
Parse a frequency string into a Jalali offset instance.
Supports formats like: - "JME" -> JalaliMonthEnd(n=1) - "2JME" -> JalaliMonthEnd(n=2) - "-1JQS" -> JalaliQuarterBegin(n=-1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq_str
|
str
|
The frequency string to parse. |
required |
Returns:
| Type | Description |
|---|---|
JalaliOffset
|
A Jalali offset instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the frequency string is not recognized. |
Source code in jalali_pandas/offsets/aliases.py
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 | |
register_jalali_alias ¶
register_jalali_alias(alias: str, offset_class: type[JalaliOffset]) -> None
Register a frequency alias for a Jalali offset class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The frequency alias string (e.g., "JME", "JQS"). |
required |
offset_class
|
type[JalaliOffset]
|
The offset class to register. |
required |
Source code in jalali_pandas/offsets/aliases.py
23 24 25 26 27 28 29 30 31 | |
Base class for Jalali calendar offsets.
JalaliOffset ¶
Bases: ABC
Abstract base class for Jalali calendar-aware offsets.
This class provides the foundation for implementing calendar-aware date offsets that respect Jalali calendar rules.
Attributes:
| Name | Type | Description |
|---|---|---|
n |
int
|
Number of periods. |
normalize |
bool
|
Whether to normalize to midnight. |
Source code in jalali_pandas/offsets/base.py
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 | |
__add__
abstractmethod
¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add offset to a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
84 85 86 87 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality.
Source code in jalali_pandas/offsets/base.py
60 61 62 63 64 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/offsets/base.py
66 67 68 | |
__init__ ¶
__init__(n: int = 1, normalize: bool = False) -> None
Initialize JalaliOffset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of periods. Defaults to 1. |
1
|
normalize
|
bool
|
Whether to normalize to midnight. Defaults to False. |
False
|
Source code in jalali_pandas/offsets/base.py
26 27 28 29 30 31 32 33 34 | |
__mul__ ¶
__mul__(other: int) -> JalaliOffset
Multiply offset by integer.
Source code in jalali_pandas/offsets/base.py
74 75 76 77 78 | |
__neg__ ¶
__neg__() -> JalaliOffset
Return negated offset.
Source code in jalali_pandas/offsets/base.py
70 71 72 | |
__radd__ ¶
__radd__(other: JalaliTimestamp) -> JalaliTimestamp
Right add offset to a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
89 90 91 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/offsets/base.py
56 57 58 | |
__rmul__ ¶
__rmul__(other: int) -> JalaliOffset
Right multiply offset by integer.
Source code in jalali_pandas/offsets/base.py
80 81 82 | |
__sub__
abstractmethod
¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract offset from a JalaliTimestamp.
Source code in jalali_pandas/offsets/base.py
93 94 95 96 | |
is_on_offset
abstractmethod
¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on offset boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if on offset boundary. |
Source code in jalali_pandas/offsets/base.py
122 123 124 125 126 127 128 129 130 131 132 | |
rollback
abstractmethod
¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous valid date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to roll back. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Rolled back JalaliTimestamp. |
Source code in jalali_pandas/offsets/base.py
110 111 112 113 114 115 116 117 118 119 120 | |
rollforward
abstractmethod
¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next valid date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
JalaliTimestamp
|
JalaliTimestamp to roll forward. |
required |
Returns:
| Type | Description |
|---|---|
JalaliTimestamp
|
Rolled forward JalaliTimestamp. |
Source code in jalali_pandas/offsets/base.py
98 99 100 101 102 103 104 105 106 107 108 | |
Jalali month offsets.
JalaliMonthBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali month.
Source code in jalali_pandas/offsets/month.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add months to timestamp, landing on month start.
Source code in jalali_pandas/offsets/month.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract months from timestamp.
Source code in jalali_pandas/offsets/month.py
43 44 45 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on month start.
Source code in jalali_pandas/offsets/month.py
69 70 71 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous month start.
Source code in jalali_pandas/offsets/month.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next month start if not already on one.
Source code in jalali_pandas/offsets/month.py
47 48 49 50 51 | |
JalaliMonthEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali month.
Source code in jalali_pandas/offsets/month.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add months to timestamp, landing on month end.
Source code in jalali_pandas/offsets/month.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract months from timestamp.
Source code in jalali_pandas/offsets/month.py
104 105 106 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on month end.
Source code in jalali_pandas/offsets/month.py
140 141 142 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous month end.
Source code in jalali_pandas/offsets/month.py
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 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next month end if not already on one.
Source code in jalali_pandas/offsets/month.py
108 109 110 111 112 | |
Jalali quarter offsets.
JalaliQuarterBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali quarter.
Source code in jalali_pandas/offsets/quarter.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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add quarters to timestamp, landing on quarter start.
Source code in jalali_pandas/offsets/quarter.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 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract quarters from timestamp.
Source code in jalali_pandas/offsets/quarter.py
52 53 54 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on quarter start.
Source code in jalali_pandas/offsets/quarter.py
80 81 82 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to current quarter start.
Source code in jalali_pandas/offsets/quarter.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next quarter start if not already on one.
Source code in jalali_pandas/offsets/quarter.py
56 57 58 59 60 | |
JalaliQuarterEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali quarter.
Source code in jalali_pandas/offsets/quarter.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add quarters to timestamp, landing on quarter end.
Source code in jalali_pandas/offsets/quarter.py
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 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract quarters from timestamp.
Source code in jalali_pandas/offsets/quarter.py
119 120 121 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on quarter end.
Source code in jalali_pandas/offsets/quarter.py
156 157 158 159 160 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous quarter end.
Source code in jalali_pandas/offsets/quarter.py
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 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next quarter end if not already on one.
Source code in jalali_pandas/offsets/quarter.py
123 124 125 126 127 | |
Jalali year offsets.
JalaliYearBegin ¶
Bases: JalaliOffset
Offset to the beginning of a Jalali year (Nowruz).
Source code in jalali_pandas/offsets/year.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add years to timestamp, landing on year start (Nowruz).
Source code in jalali_pandas/offsets/year.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract years from timestamp.
Source code in jalali_pandas/offsets/year.py
40 41 42 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on year start (Nowruz - 1 Farvardin).
Source code in jalali_pandas/offsets/year.py
67 68 69 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to current year start.
Source code in jalali_pandas/offsets/year.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next year start if not already on one.
Source code in jalali_pandas/offsets/year.py
44 45 46 47 48 | |
JalaliYearEnd ¶
Bases: JalaliOffset
Offset to the end of a Jalali year.
Source code in jalali_pandas/offsets/year.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add years to timestamp, landing on year end.
Source code in jalali_pandas/offsets/year.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract years from timestamp.
Source code in jalali_pandas/offsets/year.py
100 101 102 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on year end (last day of Esfand).
Source code in jalali_pandas/offsets/year.py
131 132 133 134 135 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous year end.
Source code in jalali_pandas/offsets/year.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next year end if not already on one.
Source code in jalali_pandas/offsets/year.py
104 105 106 107 108 | |
Jalali week offset.
JalaliWeek ¶
Bases: JalaliOffset
Offset to a specific day of the Jalali week.
The Jalali week starts on Saturday (weekday=0) and ends on Friday (weekday=6).
Attributes:
| Name | Type | Description |
|---|---|---|
weekday |
int
|
The target weekday (0=Saturday, 6=Friday). Defaults to 0 (Saturday). |
Source code in jalali_pandas/offsets/week.py
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 | |
__add__ ¶
__add__(other: JalaliTimestamp) -> JalaliTimestamp
Add weeks to timestamp, landing on target weekday.
Source code in jalali_pandas/offsets/week.py
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 | |
__eq__ ¶
__eq__(other: object) -> bool
Check equality.
Source code in jalali_pandas/offsets/week.py
65 66 67 68 69 70 71 72 73 | |
__hash__ ¶
__hash__() -> int
Hash for use in sets and dicts.
Source code in jalali_pandas/offsets/week.py
75 76 77 | |
__init__ ¶
__init__(n: int = 1, normalize: bool = False, weekday: int = SATURDAY) -> None
Initialize JalaliWeek offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of weeks. Defaults to 1. |
1
|
normalize
|
bool
|
Whether to normalize to midnight. Defaults to False. |
False
|
weekday
|
int
|
Target weekday (0=Saturday, 6=Friday). Defaults to 0 (Saturday). |
SATURDAY
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If weekday is not in range 0-6. |
Source code in jalali_pandas/offsets/week.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
__mul__ ¶
__mul__(other: int) -> JalaliWeek
Multiply offset by integer.
Source code in jalali_pandas/offsets/week.py
83 84 85 86 87 88 89 | |
__neg__ ¶
__neg__() -> JalaliWeek
Return negated offset.
Source code in jalali_pandas/offsets/week.py
79 80 81 | |
__repr__ ¶
__repr__() -> str
String representation.
Source code in jalali_pandas/offsets/week.py
61 62 63 | |
__sub__ ¶
__sub__(other: JalaliTimestamp) -> JalaliTimestamp
Subtract weeks from timestamp.
Source code in jalali_pandas/offsets/week.py
136 137 138 | |
is_on_offset ¶
is_on_offset(dt: JalaliTimestamp) -> bool
Check if date is on target weekday.
Source code in jalali_pandas/offsets/week.py
178 179 180 | |
rollback ¶
rollback(dt: JalaliTimestamp) -> JalaliTimestamp
Roll back to previous target weekday.
Source code in jalali_pandas/offsets/week.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
rollforward ¶
rollforward(dt: JalaliTimestamp) -> JalaliTimestamp
Roll forward to next target weekday if not already on one.
Source code in jalali_pandas/offsets/week.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |