
    4imH                       S SK Jr  S SKJr  S SKrS SKJr  S SKJ	r	  S SK
JrJrJrJr  S SKJrJrJrJrJr  S SKJr  S S	KJrJr  S S
KJrJrJr  S SKJr  S SK J!r!J"r"  S SK#J$r$  S SK%J&r&J'r'J(r(  S SK)J*r*J+r+  S SK,J-r-  \(       a  S SK.J/r/  S SK0J1r1J2r2J3r3  S SK4J5r5  / SQr6\6 H  r7\ H  r8\7 S\8 3r9\\7   \\9'   M     M     S H  r7\ H  r8\7 S\8 3r:\:\\:'   M     M     \ H  r;S\; 3\S\; 3'   M     S*S jr<\"" S5          S+S j5       r= " S S5      r> " S S\>5      r?S,S jr@S-S  jrAS.S! jrBS.S" jrCS/S# jrDS0S$ jrES1S% jrFS1S& jrGS1S' jrHS1S( jrI/ S)QrJg)2    )annotations)TYPE_CHECKINGN)lib)unique_deltas)	Timestampget_unit_from_dtypeperiods_per_daytz_convert_from_utc)DAYSMONTH_ALIASESMONTH_NUMBERSMONTHSint_to_weekday)OFFSET_TO_PERIOD_FREQSTR)build_field_sarraymonth_position_check)
DateOffsetDay	to_offset)get_rule_month)cache_readonly
set_module)is_numeric_dtype)
ArrowDtypeDatetimeTZDtypePeriodDtype)ABCIndex	ABCSeries)unique)npt)DatetimeIndexSeriesTimedeltaIndex)DatetimeLikeArrayMixin)QSBQEBQSYSBYEBYS-)YQW-c                0    [         R                  " U S5      $ )z,
Alias to closest period strings BQ->Q etc.
N)r   get)
offset_strs    \/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/pandas/tseries/frequencies.pyget_period_aliasr3   O   s     $''
D99    pandasc                   SSK Jn  [        U [        5      (       a  U R                  n[        U R
                  [        5      (       aH  SSKnUR                  R                  UR
                  R                  5      (       a  UR                  5       n[        R                  " UR
                  S5      (       dK  [        UR
                  [        5      (       d,  UR
                  [        :X  d  [!        SU R
                   35      eUn [#        U S5      (       d  O[        U R
                  [$        5      (       a  [!        S5      e[        R                  " U R
                  S5      (       a  ['        U 5      nUR)                  5       $ [+        U R
                  5      (       a  [!        S	U R
                   35      e[        X5      (       d  U" U S
S9n [-        U 5      nUR)                  5       $ )a0  
Infer the most likely frequency given the input index.

This method attempts to deduce the most probable frequency (e.g., 'D' for daily,
'H' for hourly) from a sequence of datetime-like objects. It is particularly useful
when the frequency of a time series is not explicitly set or known but can be
inferred from its values.

Parameters
----------
index : DatetimeIndex, TimedeltaIndex, Series or array-like
  If passed a Series will use the values of the series (NOT THE INDEX).

Returns
-------
str or None
    None if no discernible frequency.

Raises
------
TypeError
    If the index is not datetime-like.
ValueError
    If there are fewer than three values.

See Also
--------
date_range : Return a fixed frequency DatetimeIndex.
timedelta_range : Return a fixed frequency TimedeltaIndex with day as the default.
period_range : Return a fixed frequency PeriodIndex.
DatetimeIndex.freq : Return the frequency object if it is set, otherwise None.

Examples
--------
>>> idx = pd.date_range(start="2020/12/01", end="2020/12/30", periods=30)
>>> pd.infer_freq(idx)
'D'
r   )r!   NmMz>cannot infer freq from a non-convertible dtype on a Series of dtypezJPeriodIndex given. Check the `freq` attribute instead of using infer_freq.mz8cannot infer freq from a non-convertible index of dtype F)copy)pandas.core.apir!   
isinstancer   _valuesr8   r   pyarrowtypesis_timestamppyarrow_dtype_to_datetimearrayr   is_np_dtyper   object	TypeErrorhasattrr   _TimedeltaFrequencyInfererget_freqr   _FrequencyInferer)indexr!   valuespainferers        r2   
infer_freqrN   Z   sy   T .%##ekk:.. xx$$V\\%?%?@@113 OOFLL$//&,,88||v%""'++0   5'""	EKK	-	-X
 	
 
c	*	*,U3!!	%++	&	&Fu{{mT
 	
 e++e%0&Gr4   c                  D   \ rS rSrSrSS jr\SS j5       r\SS j5       r\SS j5       r	\SS j5       r
SS jr\SS	 j5       r\SS
 j5       r\SS j5       r\SS j5       rSS jr\SS j5       r\SS j5       rSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg) rI      z0
Not sure if I can avoid the state machine here
c                >   Xl         UR                  U l        [        U[        5      (       a/  [        UR                  R                  R                  5      U l	        O$[        UR                  R                  5      U l	        [        US5      (       a;  UR                  b.  [        U R                  UR                  U R                  S9U l        [        U5      S:  a  [        S5      eU R                   R                  =(       d    U R                   R                   U l        g )Ntzreso   z(Need at least 3 dates to infer frequency)rJ   asi8i8valuesr<   r   r   _data_ndarrayr8   _cresorF   rR   r
   len
ValueError_is_monotonic_increasing_is_monotonic_decreasingis_monotonic)selfrJ   s     r2   __init___FrequencyInferer.__init__   s    


 eX&& .$$**DK
 .enn.B.BCDK 5$xx# 3MM588$++! u:>GHH JJ//V4::3V3V 	r4   c                ,    [        U R                  5      $ N)r   rW   r`   s    r2   deltas_FrequencyInferer.deltas   s    T]]++r4   c                @    [        U R                  R                  5      $ rd   )r   rJ   rV   re   s    r2   deltas_asi8_FrequencyInferer.deltas_asi8   s     TZZ__--r4   c                2    [        U R                  5      S:H  $ N   )r[   rf   re   s    r2   	is_unique_FrequencyInferer.is_unique   s    4;;1$$r4   c                2    [        U R                  5      S:H  $ rl   )r[   ri   re   s    r2   is_unique_asi8 _FrequencyInferer.is_unique_asi8   s    4##$))r4   c                   U R                   (       a  U R                  R                  (       d  gU R                  S   n[	        U R
                  5      nU(       a   [        X5      (       a  U R                  5       $ U R                  SS/SS// SQ4;   a  gU R                  (       d  gU R                  S   nUS-  nUS	-  nUS	-  n[        X5      (       a  [        S
X-  5      $ [        X5      (       a  [        SX-  5      $ [        X5      (       a  [        SX-  5      $ [        XS-  5      (       a  [        SXS-  -  5      $ [        XS-  5      (       a  [        SXS-  -  5      $ [        SU5      $ )zx
Find the appropriate frequency string to describe the inferred
frequency of self.i8values

Returns
-------
str or None
Nr   rm      A   )rm   rt   ru   bh   <   hminsi  msi@B usns)r_   rJ   
_is_uniquerf   r	   rZ   _is_multiple_infer_daily_rulehour_deltasrq   ri   _maybe_add_count)r`   deltappdpphppmppss         r2   rH   _FrequencyInferer.get_freq   sS      

(=(=Adkk*\%--))++ B!R+>>
 ""  #RiRiRi###C55%%%#E5;77%%%#C55%+//#D%$;*?@@%"244#D%)3C*DEE $D%00r4   c                t    [        U R                  5      nU R                   Vs/ s H  o"U-  PM	     sn$ s  snf rd   r	   rZ   rf   )r`   r   xs      r2   
day_deltas_FrequencyInferer.day_deltas  s.    dkk*!%-AC---s   5c                z    [        U R                  5      S-  nU R                   Vs/ s H  o"U-  PM	     sn$ s  snf )Nrw   r   )r`   r   r   s      r2   r   _FrequencyInferer.hour_deltas!  s3    dkk*b0!%-AC---s   8c                >    [        U R                  U R                  S9$ )NrS   )r   rW   rZ   re   s    r2   fields_FrequencyInferer.fields&  s    !$--dkkBBr4   c                X    [        U R                  S   U R                  R                  S9$ )Nr   )unit)r   rW   rJ   r   re   s    r2   	rep_stamp_FrequencyInferer.rep_stamp*  s     q)

@@r4   c                V    [        U R                  U R                  R                  5      $ rd   )r   r   rJ   	dayofweekre   s    r2   r   &_FrequencyInferer.month_position_check.  s    #DKK1E1EFFr4   c                z    U R                   S   S-  U R                   S   -   n[        UR                  S5      5      $ )Nr,      Mi8)r   r   astype)r`   nmonthss     r2   mdiffs_FrequencyInferer.mdiffs1  s7    ++c"R'$++c*::W^^D122r4   c                P    [        U R                  S   R                  S5      5      $ )Nr,   r   )r   r   r   re   s    r2   ydiffs_FrequencyInferer.ydiffs6  s!    T[[-44T:;;r4   c                r   U R                  5       nU(       a>  U R                  S   n[        U R                  R                     nU SU 3n[        XB5      $ U R                  5       nU(       aL  U R                  S   S-  nSSSS.n[        XpR                  R                  S-        nU SU 3n[        XF5      $ U R                  5       nU(       a  [        XR                  S   5      $ U R                  (       a  U R                  5       $ U R                  5       (       a  gU R                  5       n	U	(       a  U	$ g )	Nr   r+   rU   r      
   )r      rm   B)_get_annual_ruler   r   r   monthr   _get_quarterly_ruler   _get_monthly_rulern   _get_daily_rule_is_business_daily_get_wom_rule)
r`   annual_rulenyearsr   aliasquarterly_rule	nquartersmod_dictmonthly_rulewom_rules
             r2   r   #_FrequencyInferer._infer_daily_rule:  s   ++-[[^F!$.."6"67E"m1UG,E#E22113A*I",H!(>>+?+?!+C"DEE%&aw/E#E55--/#L++a.AA>>''))""$$%%'Or4   c                    [        U R                  5      nU R                  S   U-  nUS-  S:X  a4  [        U R                  R                  5          nSU 3n[        XBS-  5      $ [        SU5      $ )Nr      r.   D)r	   rZ   rf   r   r   weekdayr   )r`   r   dayswdr   s        r2   r   !_FrequencyInferer._get_daily_ruleZ  sk    dkk*{{1~#!8q= 6 6 89BIE#E!844#C..r4   c                    [        U R                  5      S:  a  g [        [        U R                  S   5      5      S:  a  g U R	                  5       nUc  g SSSSS.R                  U5      $ )Nrm   r   r(   r*   YEr)   csbscebe)r[   r   r   r   r   r0   r`   	pos_checks     r2   r   "_FrequencyInferer._get_annual_rulee  se    t{{avdkk#&'(1,--/	e4uEII)TTr4   c                    [        U R                  5      S:  a  g U R                  S   S-  S:X  d  g U R                  5       nUc  g SSSSS.R                  U5      $ )	Nrm   r   rU   r%   r'   QEr&   r   r[   r   r   r0   r   s     r2   r   %_FrequencyInferer._get_quarterly_rules  s_    t{{a{{1~!Q&--/	e4uEII)TTr4   c                    [        U R                  5      S:  a  g U R                  5       nUc  g SSSSS.R                  U5      $ )Nrm   MSBMSMEBMEr   r   r   s     r2   r   #_FrequencyInferer._get_monthly_rule  sG    t{{a--/	e4uEII)TTr4   c                   U R                   SS/:w  a  gU R                  S   R                  5       n[        R                  " U R
                  5      n[        U R                  5      n[        R                  " X#5      n[        R                  " U[        R                  " U5      -   S5      n[        [        R                  " US:H  US:H  -  US:  US:*  -  US:H  -  -  5      5      $ )Nrm   rU   Fr   r      )r   rJ   r   npdiffrW   r	   rZ   floor_dividemodcumsumboolall)r`   first_weekdayshiftsr   weekdayss        r2   r   $_FrequencyInferer._is_business_daily  s    ??q!f$ 

1--/'dkk*-66-"))F*;;Q?FFa-FaK0qLX]3v{CE
 	
r4   c                ,   [        U R                  R                  5      n[        U5      S:  a  g [        U R                  R                  S-
  S-  5      nX"S:     n[        U5      S:X  d  [        U5      S:  a  g US   S-   n[
        US      nSU U 3$ )Nrm   r   r   r   zWOM-)r   rJ   r   r[   dayr   )r`   r   week_of_monthsweekr   s        r2   r   _FrequencyInferer._get_wom_rule  s    $**,,-x=1!!3 9:'(:;~!#s>':Q'> a 1$HQK(dVB4  r4   )rZ   rW   rJ   r_   N)returnNone)r   znpt.NDArray[np.int64]r   r   )r   
str | None)r   z	list[int])r   z
np.ndarray)r   r   )__name__
__module____qualname____firstlineno____doc__ra   r   rf   ri   rn   rq   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__ r4   r2   rI   rI      s   
> , , . .
 % % * *01d . . . . C C A AG 3 3 < <@	/UUU
&!r4   rI   c                      \ rS rSrS rSrg)rG   i  c                F    U R                   (       a  U R                  5       $ g rd   )rn   r   re   s    r2   r   ,_TimedeltaFrequencyInferer._infer_daily_rule  s    >>'')) r4   r   N)r   r   r   r   r   r   r   r4   r2   rG   rG     s    *r4   rG   c                    X-  S:H  $ )Nr   r   )r}   mults     r2   r   r     s    9>r4   c                V    US:w  a"  U[        U5      :X  d   e[        U5      nU U  3$ U $ rl   )int)basecounts     r2   r   r     s8    zE
"""E
r4   c                   Ub  U c  g[        U 5      n [        U5      n[        U5      (       a3  [        U 5      (       a  [        [	        U 5      [	        U5      5      $ U S;   $ [        U5      (       a  U S;   $ [        U5      (       a  U S;   $ [        U5      (       a  XSSSSSS	S
SS1
;   $ US:X  a  U S;   $ US:X  a  U S;   $ US:X  a  U S;   $ US:X  a  U S;   $ US:X  a  U S;   $ US	:X  a  U S;   $ US
:X  a  U S;   $ US:X  a  U S;   $ US:X  a  U S;   $ g)z
Returns True if downsampling is possible between source and target
frequencies

Parameters
----------
source : str or DateOffset
    Frequency converting from
target : str or DateOffset
    Frequency converting to

Returns
-------
bool
F>
   r   Cr   r   ry   r{   r|   r~   r}   rz   >	   r   r   r   ry   r{   r|   r~   r}   rz   r   r   r   ry   rz   r{   r|   r}   r~   >   r   ry   r{   r|   r~   r}   rz   >   r   ry   r{   r|   r~   r}   rz   >   r   ry   r{   r|   r~   r}   rz   >   ry   r{   r|   r~   r}   rz   >   r{   r|   r~   r}   rz   >   r{   r|   r~   r}   >   r|   r~   r}   >   r~   r}   >   r~   )_maybe_coerce_freq
_is_annual_is_quarterly_quarter_months_conformr   _is_monthly
_is_weekly)sourcetargets     r2   is_subperiodr    sg     ~'F'F&  *v&v(>  PPP	v		PPP	V		KKK	F		#sCeS$dSSS	3AAA	3AAA	3AAA	3<<<	5777	3000	4+++	4%%	4r4   c                n   Ub  U c  g[        U 5      n [        U5      n[        U 5      (       a]  [        U5      (       a  [        U 5      [        U5      :H  $ [        U5      (       a!  [        U 5      n[        U5      n[	        X#5      $ US;   $ [        U 5      (       a  US;   $ [        U 5      (       a  US;   $ [        U 5      (       a  XSSSSSS	S
SS1
;   $ U S:X  a  US;   $ U S:X  a  US;   $ U S:X  a  US;   $ U S:X  a  US;   $ U S:X  a  US;   $ U S	:X  a  US;   $ U S
:X  a  US;   $ U S:X  a  US;   $ U S:X  a  US;   $ g)z
Returns True if upsampling is possible between source and target
frequencies

Parameters
----------
source : str or DateOffset
    Frequency converting from
target : str or DateOffset
    Frequency converting to

Returns
-------
bool
F>
   r   r   r   r   ry   r{   r|   r~   r}   rz   >	   r   r   r   ry   r{   r|   r~   r}   rz   r   r   r   ry   rz   r{   r|   r}   r~   >   ry   r{   r|   r~   r}   rz   >   r{   r|   r~   r}   rz   >   r{   r|   r~   r}   >   r|   r~   r}   >   r~   r}   >   r~   )r   r   r   r   r  r  r  )r  r  smonthtmonths       r2   is_superperiodr
    s     ~'F'F&f!&)^F-CCC  #F+F#F+F*6::PPP	v		PPP	V		KKK	F		#sCeS$dSSS	3KKK	3KKK	3KKK	3<<<	5777	3000	4+++	4%%	4r4   c                    U c   e[        U [        5      (       a(  [        [        U R                  5      5      R
                  n U S;   a  U $ U R                  5       $ )zwe might need to coerce a code to a rule_code
and uppercase it

Parameters
----------
source : str or DateOffset
    Frequency converting from

Returns
-------
str
>   ry   r{   r|   r~   r}   rz   )r<   r   r   r   name_freqstrupper)codes    r2   r   r   8  sP     $
##9TYY/09922zz|r4   c                <    [         U    n[         U   nUS-  US-  :H  $ )NrU   )r   )r  r  snumtnums       r2   r  r  N  s)     D D!8taxr4   c                \    U R                  5       n U S:H  =(       d    U R                  S5      $ )Nr,   zY-r  
startswithrules    r2   r   r   T  %    ::<D3;/$//$//r4   c                \    U R                  5       n U S:H  =(       d    U R                  S5      $ )Nr-   )zQ-BQr  r  s    r2   r   r   Y  s%    ::<D3;7$//,77r4   c                ,    U R                  5       n U S;   $ )N)r   BM)r  r  s    r2   r  r  ^  s    ::<D;r4   c                \    U R                  5       n U S:H  =(       d    U R                  S5      $ )NWr.   r  r  s    r2   r  r  c  r  r4   )r   r3   rN   r  r
  r   )r1   strr   r   )rJ   z@DatetimeIndex | TimedeltaIndex | Series | DatetimeLikeArrayMixinr   r   )r   r   r   r   )r   r  r   floatr   r  r   )r   r  )r  r  r  r  r   r   )r  r  r   r   )K
__future__r   typingr   numpyr   pandas._libsr   pandas._libs.algosr   pandas._libs.tslibsr   r   r	   r
   pandas._libs.tslibs.ccalendarr   r   r   r   r   pandas._libs.tslibs.dtypesr   pandas._libs.tslibs.fieldsr   r   pandas._libs.tslibs.offsetsr   r   r   pandas._libs.tslibs.parsingr   pandas.util._decoratorsr   r   pandas.core.dtypes.commonr   pandas.core.dtypes.dtypesr   r   r   pandas.core.dtypes.genericr   r   pandas.core.algorithmsr   pandas._typingr    r5   r!   r"   r#   pandas.core.arrays.datetimeliker$   _need_suffix_prefix_mkey_alias_dr3   rN   rI   rG   r   r   r  r
  r   r  r   r   r  r  __all__r   r4   r2   <module>r:     s   "     ,   @ 
 7
 7 

 *" 
 G 8G	2$(@(I %  
 G9AbT"+1 (  
 B,.rd)r"Y' : HVKVV Vry! y!x*!2 *4n7t, 0
8

0
r4   