i7UdZddlmZddlmZddlmZmZmZmZm Z ddl m Z ddl Z ddl Z ddlZddlmZmZddlZddlmZmZddlZdd lmZddlZddlZdd lmZddlmcm Z!dd l"m#Z#m$Z$ddl%Z&dd l%m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z5dd l6m7Z7ddl8m9Z9m:Z:er ddl;mZ> ddl?Z@[@dZAn #eB$rdZAYnwxYweddZCdhdZDdZEdidZFdhdZGejHId ddd!ejJjKejJjLf"ejHMd d#ND]VZOePe&jQjReOZSejTeSejUeSejVd$d%ejW&Wd'ND]gZOePe&jQjReOZSejTeSejUeSejVd(d)ejWejVd*d+,-hd.ND]gZOePe&jQjReOZSejTeSejUeSejVd/d0ejWejVd*d+,1hejXd2dhd3ZYejXd2dhd4ZZejXgd5d67d8Z[ejXddg9d:Z\ejXgd;9d<Z]ejXddg9d=Z^ejXddg9d>Z_ejXddg9d?Z`ejXgd@9dAZaejXgdB9dCZbejXgdD9dEZcejXgdD9dFZdejXddGdHdIdJdKejedLe!jfdMNg9dOZgejXdGdHdIdJdKejedLe!jfdMNg9dPZhejXddg9dQZiejXgdR9dSZjejXdTdUg9dVZkejXddg9dWZlejXddg9dXZmejXgdY9dZZnejXddg9d[ZoejXddg9d\ZpejXddg9d]ZqejXdg9d^ZrejXdg9d_ZsejXe5jtd`7daZueuZvejXdejwe&jxg9dbZyeyZzejXe5j{dc7ddZ|e|Z}ejXe(e-g9deZ~ejXe9e-gdfdgg7dhZejXe9e-e&jggdi7djZejXe9e-e(e&jgdk7dlZeZejXdjdnZejXdkdpZejXdqZejXdldsZejXdmduZdvZdwZidxe9dyedzDe{d|e9d}edzDd{d~e0ddzde0ddzdde1ddzdde2ddzdde,dzde9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{de9ejdzd{ide9ddgd)ze{de9ddgd)ze{de9ejdzd{dejdzd{zzde9ejdzd{dejdzd{zzde'eddzde*jejdddde9gde:jegdgdddedede9gdde9ejdzd{de9ejdzd{de9ejdzd{de9ejdzed{de9e&jdedzDd{ZeAr3e9e&jdedzDd{Zeed<ejXe9dZejXdeD9dZejXdeD9dZejXdndZejXdndZejXdndZdZd„eDZejXdndÄZdĄe5jDZieeeZejXe9dńZdƄe5jDZieeeeZejXe9dDŽZejXdmdȄZejXdmdɄZejXdndʄZejXe)dd)˦e$dd̦fe)ddά˦e$dd̦fe+ddЬѦdfe+ddѦdfe/dd֬צdئe#dd֬٦fe.dڬۦdfg9d݄ZejXe5j9dބZejXe je7je je7je je7je je7je je7je je7je je7je je je je je je je je7je je7je je7jg9d߄ZejXe je7je je7je je7je je7je je7je je7je je7jg9dZgdZejXeͬ9dZddgZejXeϬ9dZeezZejXeѬ9dZejXe je je je je je jg9dZejXgd9dZejXgd9dZgdZejXe֬9dZejXdZejXdodZddddddddddeee je ed*e eddgZeCye۠eCdeCdeCdeC deC dfdeDZe!jeeަejXeeެ7dZe!jeed*dejXed*ded*d7dZddee jgZeCeeCjejXe9dZeZejXgd9dZeZejXe5j9dZejXd e&jfejed e&jfe!jfd Nejed ejwfe!jfd Nd ejwfggd 7d ZejXdejede!jfd Ng9d ZejXejed ejwfe!jfd Nejed e&jfe!jfd Ng9dZejXd ejed e!jfd Ng9dZejXd e&jfejed e&jfe!jfd Nejed ejwfe!jfd Nd ejwfggd 7dZejXdejed e!jfd Ng9dZeZeZejXe5j9dZejXe5j9dZejXejdxd e&jfejed e&jfe!jfd Nejed ejwfe!jfd Nd ejwfggd7dZeZejXe5j9dZejXe5j9dZejXdpdZejXe5j9dZejXe5j9dZejXe5j9dZejXe5j9dZejXe5j9dZ ejXe5j 9d Z ejXe5j 9d!Z ejXe5j9d"ZejXe5j9d#ZejXe5j9d$ZejXe5je5jz9d%ZejXe5je5jze5jze5jz9d&ZejXe5j9d'ZejXe5j9d(ZejXe5j9d)ZejXe5j9d*ZejXe5j 9d+Z!ejXe5j"9d,Z#d|d-ejwd.gfd|d-e&jd.gfd/d-e&jxd.gfd0d1ejwd2gfdejwejwejwgfdgfd3d-ejwdgfd/d-ejwd4gfd5d6ejwd4gfd7d*ejwdgfd8d*ejwd4gfd9e d*ejwe dgfddejwdgfdde&jdgfd:ej$d;ejwej$d<gfd~e/d=ejwe/d>gfd?ed@d*d*ejwedAd*d*gfdBdCejwdDgfded*ejwedgfdEed*ejwedgfde+d@e&jxe+dAgfde)dd*ejwe)ddgfgZ%dFe%DZ&ejXe%e&7dGZ'ejXdHZ(ejXdIZ)ejXdJe&jRj*D9dKZ+ejXddLg9dMZ,ejXdNdOdPejwejwejwfejwe&jxdfejwe&jdfe&je&je&jfg9dqdRZ-ejXe5j.e5j/e5j0g9dSZ1ejXe5j/e5j0g9dTZ2ejXe5j.e5j0g9dUZ3ejXe5j.e5j/g9dVZ4ejXe5j5e5j/g9dWZ6ejXe5j7e5j0g9dXZ8ejXddg9drdZZ9ejXdsd\Z:ejXdsd]Z;d^d_gZ<d`e=da<eC*e<eC d^ejXe<9dtdbZ>ejXdcZ?ejXddedfZ@ejXddg9dgZAdS(ua This file is very long and growing, but it was decided to not split it yet, as it's still manageable (2020-03-17, ~1.1k LoC). See gh-31989 Instead of splitting it was decided to define sections here: - Configuration / Settings - Autouse fixtures - Common arguments - Missing values & co. - Classes - Indices - Series' - DataFrames - Operators & Operations - Data sets/files - Time zones - Dtypes - Misc ) annotations)abc)datedatetimetime timedeltatimezone)DecimalN) TYPE_CHECKINGAny)tzlocaltzutc) strategies)import_optional_dependency)DatetimeTZDtype IntervalDtype) CategoricalIndex DataFrameInterval IntervalIndexPeriod RangeIndexSeries Timedelta Timestamp date_range period_rangetimedelta_range)ops)Index MultiIndex)CallableHashableIteratorTFpytzignore)errorsreturnNonec6|ddddS)N--no-strict-data-files store_falsez6Don't fail if a test is skipped for missing data file.)actionhelp) addoption)parsers =C:\PYTHON\_runtimes\venv\Lib\site-packages\pandas/conftest.pypytest_addoptionr2hs2   EcVddl}ddl|jjfd}||j_dS)Nrc^|r d|jvrdS|||S)N.T) isfunction __qualname__)selfmoduleobjectinspectorigs r1 _from_modulez)pytest_sessionstart.._from_modulezsA   f % % #1D*D*D4tD&&)))r3)doctestr< DocTestFinderr>)sessionr?r>r<r=s @@r1pytest_sessionstartrBpsTNNNNNN  -D*******6G&&&r3item pytest.Itempathstrmessagec|j|r7|tjd|dSdS)a~Ignore doctest warning. Parameters ---------- item : pytest.Item pytest test item. path : str Module path to Python object, e.g. "pandas.DataFrame.append". A warning will be filtered when item.name ends with in given path. So it is sufficient to specify e.g. "DataFrame.append". message : str Message to be filtered. zignore:N)nameendswith add_markerpytestmarkfilterwarnings)rCrErGs r1ignore_doctest_warningrOsZ y$I  223FW3F3FGGHHHHHIIr3c|dp|dd}gd}|r|D]}|D]\}}t|||dSdS)Nz--doctest-modulesz--doctest-cythonF)default))zapi.interchange.from_dataframe"The DataFrame Interchange Protocol)is_int64_dtypezis_int64_dtype is deprecated)is_interval_dtypezis_interval_dtype is deprecated)is_period_dtypezis_period_dtype is deprecated)is_datetime64tz_dtypez#is_datetime64tz_dtype is deprecated)is_categorical_dtypez"is_categorical_dtype is deprecated) is_sparsezis_sparse is deprecated)z&CategoricalDtype._from_values_or_dtypezConstructing a Categorical)zDataFrame.__dataframe__rR)DataFrameGroupBy.fillnaz%DataFrameGroupBy.fillna is deprecated)zDataFrameGroupBy.corrwithz'DataFrameGroupBy.corrwith is deprecated)zNDFrame.replacezSeries.replace without 'value')z NDFrame.clipz4Downcasting behavior in Series and DataFrame methods)z Series.idxminThe behavior of Series.idxmin)z Series.idxmaxThe behavior of Series.idxmax)zSeriesGroupBy.fillnaz"SeriesGroupBy.fillna is deprecated)zSeriesGroupBy.idxminrZ)zSeriesGroupBy.idxmaxr[)to_pytimedeltaz2The behavior of TimedeltaProperties.to_pytimedelta)zNDFrame.reindex_likez'keyword argument 'method' is deprecated)zmissing.mask_zero_div_zerozdivide by zero encountered)z!pandas.core.generic.NDFrame.firstzqfirst is deprecated and will be removed in a future version. Please create a mask and filter using `.loc` instead)zResampler.fillnaz+DatetimeIndexResampler.fillna is deprecated)rYz3DataFrameGroupBy.fillna with 'method' is deprecated) read_parquetz1Passing a BlockManager to DataFrame is deprecated) getoptionrO)itemsconfig is_doctestignored_doctest_warningsrCrErGs r1pytest_collection_modifyitemsrcs!!"566&:J:JE;K;;J % % % N< < rs r3)paramsidsc|jS)z@ Fixture for returning the axis numbers of a DataFrame. paramrequests r1axisr =r3)rc|jS)a Pass in the observed keyword to groupby for [True, False] This indicates whether categoricals should return values for values which are not in the grouper [False / None], or only values which appear in the grouper [True]. [None] is supported for future compatibility if we decide to change the default (and would need to warn if this parameter is not passed). rrs r1observedr  =r3)TFNc|jS)z6 Boolean 'ordered' parameter for Categorical. rrs r1orderedr+rr3c|jS)z% Boolean 'dropna' parameter. rrs r1dropnar3rr3c|jS)z# Boolean 'sort' parameter. rrs r1sortr;rr3c|jS)z% Boolean 'skipna' parameter. rrs r1skipnarCrr3)firstlastFc|jS)z[ Valid values for the 'keep' parameter used in .duplicated or .drop_duplicates rrs r1keeprK =r3)bothneitherleftrightc|jS)zA Fixture for trying all interval 'inclusive' parameters. rrs r1inclusive_endpoints_fixturerTrr3)rrrrc|jS)z< Fixture for trying all interval closed parameters. rrs r1closedr\rr3c|jS)zS Secondary closed fixture to allow parametrizing over all pairs of closed. rrs r1 other_closedrdrr3gzipbz2zipxztarzstd zstandard)marksc|jS)zK Fixture for trying common compression types in compression tests. rrs r1 compressionrl  =r3c|jS)zk Fixture for trying common compression types in compression tests excluding uncompressed case. rrs r1compression_onlyr~rr3c|jS)z, Fixture that an array is writable. rrs r1writablerrr3)innerouterrrc|jS)z: Fixture for trying all types of join operations. rrs r1 join_typerrr3nlargest nsmallestc|jS)z1 Fixture for trying all nselect methods. rrs r1nselect_methodrrr3c|jS)z2 Fixture for 'na_action' argument in map. rrs r1 na_actionrrr3c|jS)zJ Fixture for 'na_action' argument in sort_values/sort_index/rank. rrs r1 ascendingrrr3)averageminmaxrdensec|jS)z. Fixture for 'rank' argument in rank. rrs r1 rank_methodrrr3c|jS)z5 Fixture for 'as_index' argument in groupby. rrs r1as_indexrrr3c|jS)z6 Fixture for 'cache' argument in to_datetime. rrs r1cacherrr3c|jS)z> Fixture for parallel keyword argument for numba.jit. rrs r1parallelrrr3c|jS)z; Fixture for nogil keyword argument for numba.jit. rrs r1nogilrrr3c|jS)z> Fixture for nopython keyword argument for numba.jit. rrs r1nopythonrrr3c*t|jSNtype__name__rs r1rrsd1gg6Fr3c|jS)z/ Fixture for each null type in pandas. rrs r1 nulls_fixturerrr3c|jS)zL Fixture for each null type in pandas, each null type exactly once. rrs r1unique_nulls_fixturerrr3c*t|jSrrrs r1rrsQ8Hr3c|jS)z- Fixture for each NaT type in numpy. rrs r1np_nat_fixturerrr3c|jS)z; Fixture to parametrize over DataFrame and Series. rrs r1frame_or_seriesrrr3rseriesc|jS)z Fixture to parametrize over Index and Series, made necessary by a mypy bug, giving an error: List item 0 has incompatible type "Type[Series]"; expected "Type[PandasObject]" See GH#29725 rrs r1index_or_seriesrrr3)rrarrayc|jS)zG Fixture to parametrize over Index, Series, and ExtensionArray rrs r1index_or_series_or_arrayr,rr3c|jSr)rrs r1rr4s1:r3c|jS)z] Fixture to test behavior for Index, Series, DataFrame, and pandas Array classes rrs r1box_with_arrayr4rr3 type[dict]c,Gddt}|S)z, Fixture for a dictionary subclass. ceZdZddZdS)"dict_subclass..TestSubDictr(r)c0tj|g|Ri|dSr)dict__init__)r9argskwargss r1rz+dict_subclass..TestSubDict.__init__Gs( M$ 0 0 0 0 0 0 0 0 0r3Nr(r))r __module__r8rrr3r1 TestSubDictrFs( 1 1 1 1 1 1r3r)r)rs r1 dict_subclassr@s4 11111d111 r3type[abc.Mapping]c6Gddtj}|S)z8 Fixture for a non-mapping dictionary subclass. c,eZdZd dZdZd dZd dZd S) 5non_dict_mapping_subclass..TestNonDictMappingr(r)c||_dSr)_data)r9underlying_dicts r1rz>non_dict_mapping_subclass..TestNonDictMapping.__init__Ts (DJJJr3c6|j|Sr)r __getitem__)r9keys r1rzAnon_dict_mapping_subclass..TestNonDictMapping.__getitem__Ws:))#.. .r3r$c4|jSr)r__iter__r9s r1rz>non_dict_mapping_subclass..TestNonDictMapping.__iter__Zs:&&(( (r3intc4|jSr)r__len__rs r1r z=non_dict_mapping_subclass..TestNonDictMapping.__len__]s:%%'' 'r3Nr)r(r$)r(r)rrr8rrrr rr3r1TestNonDictMappingrSs_ ) ) ) ) / / / ) ) ) ) ( ( ( ( ( (r3r )rMapping)r s r1non_dict_mapping_subclassr Ms6 ( ( ( ( (S[ ( ( ( r3c ttjddt t dtddd}|d d d g }|j d |j j D|_ |j gd d|S)z DataFrame with 3 level MultiIndex (year, month, day) covering first 100 business days from 2000-01-01 with random data )dABCD 2000-01-01rBperiodsfreq)rrc|jSr)yearrs r1rzAmultiindex_year_month_day_dataframe_random_data..qsr3c|jSr)rsrs r1rzAmultiindex_year_month_day_dataframe_random_data..qs17r3c|jSr)dayrs r1rzAmultiindex_year_month_day_dataframe_random_data..qsaer3c8g|]}|dS)i8)astype).0levs r1 zCmultiindex_year_month_day_dataframe_random_data..ss$%S%S%S3cjj&6&6%S%S%Sr3)rrsrT)inplace)rrxrandom default_rngstandard_normalr listrgroupbysumr set_levelslevels set_names)tdfymds r1/multiindex_year_month_day_dataframe_random_datar.fs  a  00::d6ll##s===   C ++''):):OOL M M Q Q S SC $$%S%S#)BR%S%S%STTCII000$??? Jr3r!cBtgdgdggdgdgddgS)z; 2-level MultiIndex, lexsorted, with string names. foobarbazquxonetwothree) rrrrororrr9r9) rrorrrororrrorrsecond)r*codesnames)r!rr3r1%lexsorted_two_level_string_multiindexr=xsM ,,,.E.E.EF---/M/M/MN!   r3rc|}ttjdd|t gddS)z2DataFrame with 2 level MultiIndex with random datar) r9)ArCexprIrr)rrxr#r$r%r )r=rs r1 multiindex_dataframe_random_datarEsX 2E  a  0099oooE222   r3ctgd}tddg}tjgd}tjgd}ddg}t||g||g|d S) zJ MultiIndex used to test the general functionality of this object r0r6r7)rrrorr9r9)rrorrorrorr:F)r*r;r<verify_integrity)r rxrr!) major_axis minor_axis major_codes minor_codes index_namess r1_create_multiindexrMs 33344Ju~&&J(---..K(---..KH%K J'K(    r3c `tjddgddgtdddggd  S) zB MultiIndex with a level that is a tzaware DatetimeIndex. rorab20130101r9 US/Easternrtzr5)r<)r! from_productrrr3r1_create_mi_with_dt64tz_levelrVsH  " Q#sZ A,OOOP%%%   r3r;cg|]}d|Spandas_rris r1r!r!666q]q]]666r3r?dtypestringcg|]}d|SrXrrZs r1r!r!r\r3rz 2020-01-01)rz datetime-tzz US/PacificrSperiodDrrz1 day)startrrrangeint8int16int32int64uint8uint16uint32uint64float32float64z bool-object bool-dtype complex64y? complex128 categoricalabcdrintervalr )numemptytuples)r1r2r3)rorr9)strictmi-with-dt64tz-levelmultirepeats)rrrororr nullable_intInt64 nullable_uintUInt16nullable_floatFloat32 nullable_boolbooleanz string-pythoncg|]}d|SrXrrZs r1r!r!s333A-A--333r3zstring[python]cg|]}d|SrXrrZs r1r!r!s;;;A-A--;;;r3zstring[pyarrow]zstring-pyarrowcNt|jdS)z Fixture for many "simple" kinds of indices. These indices are unlikely to cover corner cases, e.g. - no names - no NaTs/NaNs - no values near implementation bounds - ... Fdeep) indices_dictrcopyrs r1rrs"  & + + + 7 77r3cBg|]\}}t|t|Sr) isinstancer!rrvalues r1r!r!s;   U*UJ:W:W     r3cR|j}t|dS)z8 index fixture, but excluding MultiIndex cases. Fr)rrr)rrs r1 index_flatrs' -C   ! !u ! - --r3ctg|]5\}}|ds|dvt|t3|6S))ruintfloat)rdrwr|ro) startswithrr!rs r1r!r!s_    C NN3 4 4   AAA5*--B BAAr3c^t|j}|jdvrV|}dg|dddR|d<dg|dddR|d<tj|S|j}d|d<d|d<t||dS)z Fixture for indices with missing values. Integer-dtype and empty cases are excluded because they cannot hold missing values. MultiIndex is excluded because isna() is not defined for MultiIndex. )rxrzr{NrroF)r)rrtolistr! from_tuplesvaluesrr)rindvalss r1index_with_missingrs( w} %C}CCCzz||&$q'!""+&&Q(48ABB<((R%d+++z  QRtCyyE****r3rc ttjdtjdzt dt dDdS)zC Fixture for Series of floats with Index of unique strings r]g?cg|]}d|S)i_rrZs r1r!z!string_series..(s111!X!XX111r3rrrI)rrxarangernr rdrr3r1 string_seriesr!sW  "BJ'''#-11uRyy11122    r3cdtdD}tdtdD}t||dtS)zI Fixture for Series of dtype object with Index of unique strings cg|]}d|Sfoo_rrZs r1r!z!object_series..2s * * *1J1JJ * * *r3rcg|]}d|S)bar_rrZs r1r!z!object_series..3s111!:!::111r3objectsrrIr^)rdr rr;)datars r1 object_seriesr-sV + *b * * *D 11uRyy111 2 2E $e)6 B B BBr3cttjddt ddddS)z9 Fixture for Series of floats with DatetimeIndex rrrrrtsr)rrxr#r$r%rrr3r1datetime_seriesr7sQ  a  0044r<<<    r3ct|}tjd|}t ||ddS)zHelper for the _series dictrrOF)rrIr)lenrxr#r$r%r)rsizers r1_create_seriesrCsG u::D 9  # # 3 3D 9 9D $e#E : : ::r3c<i|]\}}d|dt|S)z series-with-z-indexr)rindex_idrs r1 rJsA   %$8###^E%:%:   r3c t|S)zE Fixture for tests on series with changing types of indices. rrs r1series_with_simple_indexrPs %  r3c i|]B}|jdttddtdDd|CS)-seriesrcg|]}d|S)zi-rrZs r1r!z.Zs666q(q((666r3rOr)rrrdrr^s r1rrXsj  ~ b 66E"II666S!!!r3cNt|jdS)z| Fixture for tests on indexes, series and series with a narrow dtype copy to avoid mutation, e.g. setting .name Fr)_index_or_series_objsrrrs r1index_or_series_objrcs" ! / 4 4% 4 @ @@r3c>i|]}|jdt|S)r)rrrs r1rrls827u~u r3cNt|jdS)z Fixture for tests on indexes, series, series with a narrow dtype and series with empty objects type copy to avoid mutation, e.g. setting .name Fr)_index_or_series_memory_objsrrrs r1index_or_series_memory_objrys" ( 6 ; ; ; G GGr3c ttjdtjt dt dDt t dS)zj Fixture for DataFrame of ints with index of unique strings Columns are ['A', 'B', 'C', 'D'] rrr]cg|]}d|SrrrZs r1r!zint_frame..333AZAZZ333r3rrrD)rrxonesrhr rdr&rr3r1 int_framers`  rx(((33r33344d6ll##   r3c ttjddt dt dDt tdS)zm Fixture for DataFrame of floats with index of unique strings Columns are ['A', 'B', 'C', 'D']. rrcg|]}d|SrrrZs r1r!zfloat_frame..rr3rrrD)rrxr#r$r%r rdr&rr3r1 float_framersm  a  009933r33344d6ll##   r3ctdddtdddtdddtdddtdddtdddtdddtdddtdddtdddg }ttjdt ||S)zF Fixture for Series with a DatetimeIndex that has duplicates. irorr9rrnr)rrrxr#r$r%r)datess r1(rand_series_with_duplicate_datetimeindexrs q!q!q!q!q!q!q!q!q!q! E ")''**::3u::FFe T T TTr3)rrrg?g?z2012-01M)rz period[M]z 2012-02-01z period[D]z 2011-01-01rR)rTs)unitrTi)secondsztimedelta64[us]c|jS)z; Fixture that tests each scalar and datetime type. rrs r1ea_scalar_and_dtyper " =r3c|jS)zD Fixture for dunder names for common arithmetic operations. rrs r1all_arithmetic_operatorsrrr3c|jS)zU Fixture for operator and roperator arithmetic, comparison, and logical ops. rrs r1all_binary_operatorsr D =r3c|jS)z Fixture for operator and roperator arithmetic functions. Notes ----- This includes divmod and rdivmod, whereas all_arithmetic_operators does not. rrs r1all_arithmetic_functionsrs 6 =r3) countr(rrmeanprodstdvarmediankurtskewsemc|jS)z. Fixture for numeric reduction names. rrs r1all_numeric_reductionsr.rr3allanyc|jS)z. Fixture for boolean reduction names. rrs r1all_boolean_reductionsr9rr3c|jS)z> Fixture for all (boolean + numeric) reduction names. rrs r1all_reductionsrDrr3c|jS)z; Fixture for operator module comparison functions. rrs r1 comparison_oprL  =r3)__le____lt____ge____gt__c|jS)zm Fixture for dunder names for compare operations except == and != * >= * > * < * <= rrs r1compare_operators_no_eq_ner]rr3)__and____rand____or____ror____xor____rxor__c|jS)zY Fixture for dunder names for common logical operations * | * & * ^ rrs r1all_logical_operatorsrj  =r3)cumsumcumprodcummincummaxc|jS)z0 Fixture for numeric accumulation names rrs r1all_numeric_accumulationsr {rr3c,|dS)zR Returns the configuration for the test setting `--no-strict-data-files`. r+)r^) pytestconfigs r1strict_data_filesr s  ! !": ; ;;r3r Callable[..., str]ctjtjtdfd}|S)aD Get the path to a data file. Parameters ---------- path : str Path to the file, relative to ``pandas/tests/`` Returns ------- path including ``pandas/tests``. Raises ------ ValueError If the path doesn't exist and the --no-strict-data-files option is not set. testsctjjg|R}tj|s-rt d|dt jd|d|S)NzCould not find file z' and --no-strict-data-files is not set.zCould not find r6)osrEjoinexists ValueErrorrLskip)rrE BASE_PATHr s r1decozdatapath..decos}w|I----w~~d## 3   X4XXX K1$111 2 2 2 r3)rrErdirname__file__)r rrs` @r1datapathrsN& RW__X66@@I Kr3UTCz Asia/Tokyozdateutil/US/Pacificzdateutil/Asia/Singaporez+01:15z-02:15z UTC+01:15z UTC-02:15)hoursrr1rCi,ic,g|]}t|Sr)reprrZs r1r!r!s+++AQ+++r3c|jS)zD Fixture for trying timezones including default (None): {0} rrs r1tz_naive_fixturer!rr3c|jS)z4 Fixture for trying explicit timezones: {0} rrs r1tz_aware_fixturer#rr3utcz dateutil/UTCc|jS)zQ Fixture to provide variants of UTC timezone strings and tzinfo objects. rrs r1 utc_fixturer&rr3)rmsusnsc|jS)z& datetime64 units we support. rrs r1rrrr3c|jS)zR Parametrized fixture for string dtypes. * str * 'str' * 'U' rrs r1 string_dtyper,  =r3pythonpyarrow)string=string[python]string=string[pyarrow]string=str[pyarrow]string=str[python]c@|j\}}tj||S)z Parametrized fixture for string dtypes. * 'string[python]' (NA variant) * 'string[pyarrow]' (NA variant) * 'str' (NaN variant, with pyarrow) * 'str' (NaN variant, without pyarrow) )rry StringDtyperstoragena_values r1string_dtype_no_objectr9s"0 GX >'8 , ,,r3c|jS)za Parametrized fixture for string dtypes. * 'string[python]' * 'string[pyarrow]' rrs r1nullable_string_dtyper;*  =r3c(tj|jS)zq Parametrized fixture for string dtypes backed by Pyarrow. * 'str[pyarrow]' * 'string[pyarrow]' )ryr5rrs r1pyarrow_string_dtyper>:s >7= ))r3c|jSzb Parametrized fixture for pd.options.mode.string_storage. * 'python' * 'pyarrow' rrs r1string_storagerAJr<r3c|jS)z Parametrized fixture for StringDtype storage and na_value. * 'python' + pd.NA * 'pyarrow' + pd.NA * 'pyarrow' + np.nan rrs r1string_dtype_argumentsrCZs , =r3numpy_nullablec|jSr@rrs r1 dtype_backendrFsr<r3c|jS)zK Parametrized fixture for bytes dtypes. * bytes * 'bytes' rrs r1 bytes_dtyperH  =r3c|jS)zN Parametrized fixture for object dtypes. * object * 'object' rrs r1 object_dtyperKrIr3)z string=objectr0r1r2r3ct|jtjr|jS|j\}}t j||S)z Parametrized fixture for string dtypes. * 'object' * 'string[python]' (NA variant) * 'string[pyarrow]' (NA variant) * 'str' (NaN variant, with pyarrow) * 'str' (NaN variant, without pyarrow) )rrrxr^ryr5r6s r1any_string_dtyperMsB2'-**1}$M~gx000r3c|jS)z\ Parametrized fixture for datetime64 dtypes. * 'datetime64[ns]' * 'M8[ns]' rrs r1datetime64_dtyperOrIr3c|jS)z^ Parametrized fixture for timedelta64 dtypes. * 'timedelta64[ns]' * 'm8[ns]' rrs r1timedelta64_dtyperQrIr3rc .tdddddddS)z- Fixture emits fixed Timestamp.now() irorpr )rrsrhourminuter: microsecond)rrr3r1 fixed_now_tsrXs*  1RR   r3c|jS)z^ Parameterized fixture for float dtypes. * float * 'float32' * 'float64' rrs r1float_numpy_dtyperZr-r3c|jS)zR Parameterized fixture for float dtypes. * 'Float32' * 'Float64' rrs r1float_ea_dtyper\rIr3c|jS)z~ Parameterized fixture for float dtypes. * float * 'float32' * 'float64' * 'Float32' * 'Float64' rrs r1any_float_dtyper^rr3c|jS)zg Parameterized fixture for complex dtypes. * complex * 'complex64' * 'complex128' rrs r1 complex_dtyper`r-r3c|jS)z Parameterized fixture for complex and numpy float dtypes. * complex * 'complex64' * 'complex128' * float * 'float32' * 'float64' rrs r1complex_or_float_dtyperbs  =r3c|jS)z| Parameterized fixture for signed integer dtypes. * int * 'int8' * 'int16' * 'int32' * 'int64' rrs r1any_signed_int_numpy_dtyperd#rr3c|jS)zx Parameterized fixture for unsigned integer dtypes. * 'uint8' * 'uint16' * 'uint32' * 'uint64' rrs r1any_unsigned_int_numpy_dtyperf1rr3c|jS)z Parameterized fixture for any integer dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' rrs r1any_int_numpy_dtyperh>rr3c|jS)z Parameterized fixture for any nullable integer dtype. * 'UInt8' * 'Int8' * 'UInt16' * 'Int16' * 'UInt32' * 'Int32' * 'UInt64' * 'Int64' rrs r1any_int_ea_dtyperjPrr3c|jS)a. Parameterized fixture for any nullable integer dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * 'UInt8' * 'Int8' * 'UInt16' * 'Int16' * 'UInt32' * 'Int32' * 'UInt64' * 'Int64' rrs r1 any_int_dtyperlas . =r3c|jS)z Parameterized fixture for any nullable integer dtype and any float ea dtypes. * 'UInt8' * 'Int8' * 'UInt16' * 'Int16' * 'UInt32' * 'Int32' * 'UInt64' * 'Int64' * 'Float32' * 'Float64' rrs r1any_numeric_ea_dtypern{rr3c|jS)a Parameterized fixture for any nullable integer dtype and any float ea dtypes. * 'UInt8' * 'Int8' * 'UInt16' * 'Int16' * 'UInt32' * 'Int32' * 'UInt64' * 'Int64' * 'Float32' * 'Float64' * 'uint8[pyarrow]' * 'int8[pyarrow]' * 'uint16[pyarrow]' * 'int16[pyarrow]' * 'uint32[pyarrow]' * 'int32[pyarrow]' * 'uint64[pyarrow]' * 'int64[pyarrow]' * 'float32[pyarrow]' * 'float64[pyarrow]' rrs r1any_numeric_ea_and_arrow_dtyperps @ =r3c|jS)z~ Parameterized fixture for any signed nullable integer dtype. * 'Int8' * 'Int16' * 'Int32' * 'Int64' rrs r1any_signed_int_ea_dtyperrrr3c|jS)z Parameterized fixture for any (purely) real numeric dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * float * 'float32' * 'float64' rrs r1any_real_numpy_dtyperts $ =r3c|jS)a  Parameterized fixture for any (purely) real numeric dtype. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * float * 'float32' * 'float64' and associated ea dtypes. rrs r1any_real_numeric_dtypervs ( =r3c|jS)a Parameterized fixture for all numpy dtypes. * bool * 'bool' * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * float * 'float32' * 'float64' * complex * 'complex64' * 'complex128' * str * 'str' * 'U' * bytes * 'bytes' * 'datetime64[ns]' * 'M8[ns]' * 'timedelta64[ns]' * 'm8[ns]' * object * 'object' rrs r1any_numpy_dtyperxrr3c|jS)a Parameterized fixture for all real dtypes that can hold NA. * float * 'float32' * 'float64' * 'Float32' * 'Float64' * 'UInt8' * 'UInt16' * 'UInt32' * 'UInt64' * 'Int8' * 'Int16' * 'Int32' * 'Int64' * 'uint8[pyarrow]' * 'uint16[pyarrow]' * 'uint32[pyarrow]' * 'uint64[pyarrow]' * 'int8[pyarrow]' * 'int16[pyarrow]' * 'int32[pyarrow]' * 'int64[pyarrow]' * 'float[pyarrow]' * 'double[pyarrow]' rrs r1any_real_nullable_dtyperzs : =r3c|jS)a Parameterized fixture for all numeric dtypes. * int * 'int8' * 'uint8' * 'int16' * 'uint16' * 'int32' * 'uint32' * 'int64' * 'uint64' * float * 'float32' * 'float64' * complex * 'complex64' * 'complex128' * 'UInt8' * 'Int8' * 'UInt16' * 'Int16' * 'UInt32' * 'Int32' * 'UInt64' * 'Int64' * 'Float32' * 'Float64' rrs r1any_numeric_dtyper|2s > =r3rOcmixedbytesacz mixed-integerg@floatingg?integerzmixed-integer-floatdecimal datetime64z 2013-01-01z 2018-01-01rQ20180101riicomplexy??y@@rcg|] }|d S)rr)rpairs r1r!r!ps)DGr3cT|j\}}tj|t}||fS)a Fixture for all inferred dtypes from _libs.lib.infer_dtype The covered (inferred) types are: * 'string' * 'empty' * 'bytes' * 'mixed' * 'mixed-integer' * 'mixed-integer-float' * 'floating' * 'integer' * 'decimal' * 'boolean' * 'datetime64' * 'datetime' * 'date' * 'timedelta' * 'time' * 'period' * 'interval' Returns ------- inferred_dtype : str The string for the inferred dtype from _libs.lib.infer_dtype values : np.ndarray An array of object dtype that will be inferred to have `inferred_dtype` Examples -------- >>> from pandas._libs import lib >>> >>> def test_something(any_skipna_inferred_dtype): ... inferred_dtype, values = any_skipna_inferred_dtype ... # will pass ... assert lib.infer_dtype(values, skipna=True) == inferred_dtype r])rrxrr;)rinferred_dtypers r1any_skipna_inferred_dtyperus2R%]NF XfF + + +F 6 !!r3ctjddddlm}ddlm}|}d|j_||S) zj Get an instance of IPython.InteractiveShell. Will raise a skip if IPython is not installed. IPythonz6.0.0) minversionr)InteractiveShell)Configz:memory:)r`)rL importorskipIPython.core.interactiveshellrtraitlets.configrHistoryManager hist_file)rrr}s r1iprsj  g6666>>>>>>('''''A!+A  1 % % %%r3c#Ktjd}tjd}tjd}|j} |5|ddVdddn #1swxYwY|j|j||dtj ddS#|j|j||dtj dwxYw)a* Ensure Matplotlib is cleaned up around a test. Before a test is run: 1) Set the backend to "template" to avoid requiring a GUI. After a test is run: 1) Reset units registry 2) Reset rc_context 3) Close all figures See matplotlib/testing/decorators.py#L24. matplotlibzmatplotlib.unitszmatplotlib.pyplottemplateNrro) rLrregistryr rc_contextuseclearupdateclosegccollect)mpl mpl_unitspltorig_units_registrys r1 mpl_cleanuprsz"  l + +C#$677I  1 2 2C#,1133  ^^     GGJ    EEE                  """!!"5666 % 1   """!!"5666 % 1 s1C<-B C<BC<BC< > DE;;  ACN;;r3c|jS)zN Fixture for Tick based datetime offsets available for a time series. rrs r1 tick_classesrrr3c|Srrrs r1rrsr3c|jS)zk Simple fixture for testing keys in sorting methods. Tests None (no key) and the identity key. rrs r1 sort_by_keyrrr3)r1NN)EgonVenkmanN)NCC1701Drr#tuple[Hashable, Hashable, Hashable]c|jS)zP A 3-tuple of names, the first two for operands, the last for a result. rrs r1r<r<s =r3c|jS)zI Parametrize over __setitem__, loc.__setitem__, iloc.__setitem__ rrs r1 indexer_slirrr3c|jS)z< Parametrize over loc.__getitem__, iloc.__getitem__ rrs r1 indexer_lirrr3c|jS)z8 Parametrize over __setitem__, iloc.__setitem__ rrs r1 indexer_sirrr3c|jS)z7 Parametrize over __setitem__, loc.__setitem__ rrs r1 indexer_slrrr3c|jS)z: Parametrize over at.__setitem__, loc.__setitem__ rrs r1 indexer_alr&rr3c|jS)z< Parametrize over iat.__setitem__, iloc.__setitem__ rrs r1 indexer_ialr.rr3Iterator[bool | type[Warning]]c#Ktjd|j5|jrtjjndVddddS#1swxYwYdS)z Fixture to check if performance warnings are enabled. Either produces ``PerformanceWarning`` if they are enabled, otherwise ``False``. zmode.performance_warningsFN)ryoption_contextrr'PerformanceWarningrs r1performance_warningr6s 6 F FGG.5mFbi**FFFGGGGGGGGGGGGGGGGGGsAA A boolc2tjjjduS)z= Fixture to check if infer string option is enabled. T)ryoptionsfuture infer_stringrr3r1using_infer_stringr@s :  )T 11r3c2tjjjduS)NT)ryrrpython_scalarsrr3r1using_python_scalarsrHs :  +t 33r3z Europe/Warsawzdateutil/Europe/Warsawz list[Any]_warsawsc|jS)zE tzinfo for Europe/Warsaw using pytz, dateutil, or zoneinfo. rrs r1warsawrRrr3ct|ttjz }||S)z Generate a unique file for testing use. See link for removal policy. https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-default-base-temporary-directory )rFuuiduuid4touch)tmp_path file_paths r1 temp_filerZs2 3tz||,,,I OO r3rA)scopec#Ktj5}|VddddS#1swxYwYdSr)rL MonkeyPatchcontext)mps r1 monkeysessionres   # # % %s 377c#~K|j}tjd| 5|VddddS#1swxYwYdS)Nzfuture.distinguish_nan_and_na)rryr)ropts r1using_nan_is_narks -C :G D D s 266r)rCrDrErFrGrFr(r))r(r)r(r)r(r!)r(r)r(r)r rFr(r)r(r)r(r)r(r)r(r)r(rF(B__doc__ __future__r collectionsrrrrrr rr roperatorrtypingr r r dateutil.tzr r hypothesisrstnumpyrxrLpandas.compat._optionalrpandas.util._test_decoratorsutil_test_decoratorstdpandas.core.dtypes.dtypesrrpandasryrrrrrrrrrrrrpandas._testing_testingtm pandas.corerpandas.core.indexes.apir r!collections.abcr"r#r$r/pa has_pyarrow ImportErrorr%r2rBrOrcsettingsregister_profile HealthChecktoo_slowdiffering_executors load_profilesplitrIrtseriesrclsregister_type_strategybuildsintegersbooleansfixturer{rrrrrrrrrrrr skip_if_norrrrrrrrrrrrr NULL_OBJECTSrnulls_fixture2nanNaTrunique_nulls_fixture2NP_NAT_OBJECTSrnp_nat_fixture2rrrrrbox_with_array2rr r.r=rErMrVrdr;rrr& from_breakslinspacerrrridxkeysrr_rrrrrr_seriesrNARROW_NP_DTYPES_narrow_seriesrrPYTHON_DATA_TYPES_typ_objects_seriesrrrrras_unitrarithmetic_dunder_methodsraddraddsubrsubmulrmultruedivrtruedivfloordiv rfloordivmodrmodpowrpoweqneltlegtgeand_rand_xorrxoror_ror_rr_all_numeric_reductionsr_all_boolean_reductionsr_all_reductionsrrrr_all_numeric_accumulationsr r rr$ TIMEZONESextend FixedOffset TIMEZONE_IDSparametrize_fixture_docrFr!r#_UTCSappendr& utc_fixture2runit2 STRING_DTYPESr,NAr9r;r>rArCrFstring_storage2string_dtype_arguments2 BYTES_DTYPESrH OBJECT_DTYPESrKr^rMany_string_dtype2DATETIME64_DTYPESrOTIMEDELTA64_DTYPESrQrXFLOAT_NUMPY_DTYPESrZFLOAT_EA_DTYPESr\ALL_FLOAT_DTYPESr^COMPLEX_DTYPESr`COMPLEX_FLOAT_DTYPESrbSIGNED_INT_NUMPY_DTYPESrdUNSIGNED_INT_NUMPY_DTYPESrfALL_INT_NUMPY_DTYPESrhALL_INT_EA_DTYPESrjALL_INT_DTYPESrlrnALL_INT_PYARROW_DTYPES_STR_REPRFLOAT_PYARROW_DTYPES_STR_REPRrpSIGNED_INT_EA_DTYPESrrALL_REAL_NUMPY_DTYPESrtALL_REAL_DTYPESrvALL_NUMPY_DTYPESrxALL_REAL_NULLABLE_DTYPESrzALL_NUMERIC_DTYPESr|r_any_skipna_inferred_dtyperrrr__all__rrr<setitemlocilocrrrratriatrrrrr__annotations__rrrrrr3r1rjs*(#"""""   '''''' >>>>>>)))))))))                                KK KKK "!&:::666,IIII$1<1<1<1>>           V=2=#=#=>>>       e}%%%&%:::;;;<; K011121h'((()(e}%%%&%BBBCCCDCe}%%%&%e}%%%&%e}%%%&%w vr,F,FGGGHGbfbf-.../.-r(.H.HIIIJI! 6*+++,+vWh,?@@@  A@ vrx06R6R6RSSSTSvy"(;AUAUVVVWV!    0"    (* ee66EE"II666fEEE* ee66EE"II666eDDD* <444*::lB<HHH *  ll<#>>> * wEEE * ZZ^^* EE)")B--v . . .* UU929R== 0 0 0* UU929R== 0 0 0* UU929R== 0 0 0* UU929R== 0 0 0* eeIBIbMM222* eeIBIbMM222* eeIBIbMM222* uuYRYr]])444!*"uuYRYr]])444#**$55$*&999%*&%%u )666'*( "K(((4)")Bk2R2R2R+RR)*.%% "L)))D929R|3T3T3T,TT/*4##DDLL1$4555*6) )+"+a"*E*E*EFF7*8 UU2YY9*: $j$  ! ! !999T:::;*@88::A*B   ! !C*Duu'''((E*FEE)")B--w777G*HUU929R==999I*JeeIBIbMM;;;K*LUU929R==//55YGGGM*NUU33r333;KLLLO** V) %;;r;;;CTUUU V VC%(L!"|((**+++ 8 8,+ 8  *0022    ..  .  &,,..      ++  +4CCCC;;;  '--//    !!!!$ F<E7EnE,1133444AA54A;=;O        388::;;;HH<;H        UUUU. q " " "MM'7$C$CD s# & & & i(I(IJ   $ $ $k2  3 ' ' '5 Il| 4 4 4 < &>???     25 i'}r}Y/G/GHHH i(  i0H0HIII 26            YmbmI&>&>???    !0r'''('r'((()( 25 i'}r}Y/G/GHHH i(  i0H0HIII 26      11! 1$%r+,,,-,r,---.-r,---.-r)***+*r*+++  ,+ r()))*)r.///  0/ r1222  32 r3444  54 r.///0/"r+,,,  -,  r()))*)2r+b.@@AAABA*  ( ) & '   :r.///  0/ r/00010(r)***+*,r*+++!!,+!Hr233343>r,---.-FRVS!" RUC ! sBFC ! tRVT"# rvrvrv&' bMsBFA&' sBFC !#rvs#$BFAQ,-RVWWQZZ01rvu%&rue$%MBM,//|9T9TUV))J'':1F1FGH dd4AT1a(8(8 9:()99Q<<167 dd1ggrvttAww '( t bfffTll34((1a.."&((1a..9:362 1s;;;,","<;,"d&&&$@  #   kk*+++,+!,    ru       BFBG455565()))*) BG,---.- BF+,,,-,rv'''('()))*)e}%%%GGG&%G22224444'(@AAAAA OODMM/22333x   ! i   !  e}%%%&%s.B66C?C