content large_stringlengths 3 20.5k | url large_stringlengths 53 192 ⌀ | branch large_stringclasses 4
values | source large_stringclasses 51
values | embeddings listlengths 384 384 | score float64 -0.21 0.65 |
|---|---|---|---|---|---|
``r'\' == '\\'``. Replace the '.' with ``NaN`` .. ipython:: python d = {"a": list(range(4)), "b": list("ab.."), "c": ["a", "b", np.nan, "d"]} df = pd.DataFrame(d) df.replace(".", np.nan) Replace the '.' with ``NaN`` with regular expression that removes surrounding whitespace .. ipython:: python df.replace(r"\s\*\.\s\*"... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/missing_data.rst | main | pandas | [
0.017777176573872566,
-0.027553122490644455,
0.0735991895198822,
-0.06256796419620514,
0.02543541043996811,
-0.03858073800802231,
0.032464176416397095,
-0.07501362264156342,
-0.0267755389213562,
0.09453324973583221,
0.02296130359172821,
0.017684124410152435,
-0.037393223494291306,
0.009383... | -0.008358 |
.. \_dsintro: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Intro to data structures \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* We'll start with a quick, non-comprehensive overview of the fundamental data structures in pandas to get you started. The fundamental behavior about data types, indexing,... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
-0.04241251200437546,
-0.01958312653005123,
-0.002181930234655738,
-0.04172305762767792,
0.012255272828042507,
-0.08525850623846054,
-0.007606069557368755,
0.019562948495149612,
-0.07471911609172821,
-0.00043699124944396317,
0.015314963646233082,
-0.005479856859892607,
-0.07006897032260895,
... | 0.119168 |
more \*concrete\* arrays like a :class:`numpy.ndarray`. pandas knows how to take an :class:`~pandas.api.extensions.ExtensionArray` and store it in a :class:`Series` or a column of a :class:`DataFrame`. See :ref:`basics.dtypes` for more. While :class:`Series` is ndarray-like, if you need an \*actual\* ndarray, then use ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
-0.02499321475625038,
-0.024363595992326736,
-0.07587295025587082,
-0.0204149316996336,
0.014284037053585052,
-0.07467886060476303,
-0.009256834164261818,
-0.043114155530929565,
-0.04791603982448578,
-0.03540642186999321,
-0.025438329204916954,
0.03225501999258995,
-0.07352163642644882,
0.... | 0.091346 |
you pass an index and / or columns, you are guaranteeing the index and / or columns of the resulting DataFrame. Thus, a dict of Series plus a specific index will discard all data not matching up to the passed index. If axis labels are not passed, they will be constructed from the input data based on common sense rules.... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
-0.023182479664683342,
-0.017491139471530914,
-0.007805804256349802,
-0.055221106857061386,
0.01829860545694828,
-0.05300285294651985,
-0.03129297494888306,
-0.08515773713588715,
0.04742838069796562,
0.02021070010960102,
0.02386651746928692,
0.02436954341828823,
-0.05942832678556442,
-0.01... | -0.068099 |
namedtuple("Point", "x y") pd.DataFrame([Point(0, 0), Point(0, 3), (2, 3)]) Point3D = namedtuple("Point3D", "x y z") pd.DataFrame([Point3D(0, 0, 0), Point3D(0, 3, 5), Point(2, 3)]) .. \_basics.dataframe.from\_list\_dataclasses: From a list of dataclasses ~~~~~~~~~~~~~~~~~~~~~~~~~~ Data Classes as introduced in `PEP557 ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
-0.02591106854379177,
-0.06132464110851288,
-0.03568803891539574,
-0.051178473979234695,
0.025239765644073486,
-0.04834146425127983,
0.09039591997861862,
-0.05254670977592468,
-0.07555080950260162,
-0.020206332206726074,
0.030093446373939514,
0.020355327054858208,
-0.035585399717092514,
0.... | -0.004267 |
leaving the original DataFrame untouched. Passing a callable, as opposed to an actual value to be inserted, is useful when you don't have a reference to the DataFrame at hand. This is common when using :meth:`~pandas.DataFrame.assign` in a chain of operations. For example, we can limit the DataFrame to just those obser... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
0.01909266598522663,
-0.0662325918674469,
-0.02385656163096428,
0.00432246271520853,
0.09899488091468811,
-0.07200164347887039,
0.041063982993364334,
-0.024530721828341484,
-0.00870959646999836,
0.012072846293449402,
0.010061957873404026,
0.004547061864286661,
-0.07267900556325912,
0.00307... | -0.036042 |
df2 -df1 Transposing ~~~~~~~~~~~ To transpose, access the ``T`` attribute or :meth:`DataFrame.transpose`, similar to an ndarray: .. ipython:: python # only show the first 5 rows df[:5].T .. \_dsintro.numpy\_interop: DataFrame interoperability with NumPy functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Most Num... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/dsintro.rst | main | pandas | [
-0.03913166746497154,
-0.06461137533187866,
-0.03774155303835869,
-0.008645176887512207,
0.04381370544433594,
-0.13481155037879944,
-0.06649451702833176,
-0.023454593494534492,
-0.03249138593673706,
0.045111283659935,
-0.0260846596211195,
0.01213072519749403,
-0.08877341449260712,
-0.00223... | 0.109514 |
.. \_merging: {{ header }} .. ipython:: python :suppress: from matplotlib import pyplot as plt import pandas.util.\_doctools as doctools p = doctools.TablePlotter() \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Merge, join, concatenate and compare \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.017591973766684532,
-0.032719168812036514,
0.0048981402069330215,
-0.0561552569270134,
0.0403292179107666,
-0.029587889090180397,
-0.011799432337284088,
0.025490716099739075,
-0.024484004825353622,
-0.0022186352871358395,
0.06599196791648865,
-0.01739676669239998,
-0.04357745125889778,
-... | -0.045908 |
indexes on the concatenation axis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For :class:`DataFrame` objects which don't have a meaningful index, the ``ignore\_index`` ignores overlapping indexes. .. ipython:: python result = pd.concat([df1, df4], ignore\_index=True, sort=False) result .. ipython:: python :suppress: @sa... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.02927025407552719,
-0.027615342289209366,
0.015146085061132908,
-0.033303651958703995,
0.06664770096540451,
-0.05634771287441254,
0.010081326588988304,
-0.00901802722364664,
0.025906475260853767,
-0.008552228100597858,
0.07479578256607056,
0.052249711006879807,
-0.03937273100018501,
-0.0... | -0.065798 |
to one or more columns in a different :class:`DataFrame`. \* \*\*many-to-many\*\*: joining columns on columns. .. note:: When joining columns on columns, potentially a many-to-many join, any indexes on the passed :class:`DataFrame` objects \*\*will be discarded\*\*. For a \*\*many-to-many\*\* join, if a key combination... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.0729251578450203,
-0.06111437454819679,
-0.019968535751104355,
-0.0409984216094017,
0.013962800614535809,
-0.017120257019996643,
0.03927764296531677,
-0.06091364845633507,
-0.05214743688702583,
0.025397079065442085,
0.03181653469800949,
0.062060944736003876,
0.01649637334048748,
-0.02445... | -0.087263 |
the dimensions of the result and can cause a memory overflow. .. \_merging.validation: Merge key uniqueness ~~~~~~~~~~~~~~~~~~~~ The ``validate`` argument checks whether the uniqueness of merge keys. Key uniqueness is checked before merge operations and can protect against memory overflows and unexpected key duplicatio... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
-0.0018444373272359371,
-0.04161465913057327,
0.01885867491364479,
-0.036987315863370895,
0.02375497668981552,
-0.0412258543074131,
-0.0015493282116949558,
-0.02746632881462574,
0.009163453243672848,
-0.01765327900648117,
0.06050259619951248,
0.08124640583992004,
-0.010073656216263771,
-0.... | -0.073572 |
left = pd.DataFrame( { "A": ["A0", "A1", "A2", "A3"], "B": ["B0", "B1", "B2", "B3"], "key1": ["K0", "K0", "K1", "K2"], "key2": ["K0", "K1", "K0", "K1"], } ) index = pd.MultiIndex.from\_tuples( [("K0", "K0"), ("K1", "K0"), ("K2", "K0"), ("K2", "K1")] ) right = pd.DataFrame( {"C": ["C0", "C1", "C2", "C3"], "D": ["D0", "D... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.01384890265762806,
-0.025252414867281914,
0.018376195803284645,
-0.045953795313835144,
-0.012705422937870026,
-0.0068727112375199795,
0.013339291326701641,
-0.07379946857690811,
0.0014155021635815501,
0.032049618661403656,
0.0026101614348590374,
0.04008353874087334,
-0.0056943390518426895,... | 0.00734 |
joined using only some of the levels of a :class:`MultiIndex`, the extra levels will be dropped from the resulting join. To preserve those levels, use :meth:`DataFrame.reset\_index` on those level names to move those levels to columns prior to the join. .. \_merging.multiple\_join: Joining multiple :class:`DataFrame` ~... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.026229936629533768,
-0.03071201965212822,
0.0013532962184399366,
0.006773172412067652,
0.0852629616856575,
-0.02258906699717045,
-0.019452214241027832,
0.01901647448539734,
-0.059416014701128006,
-0.018322311341762543,
0.003238111501559615,
0.03093772567808628,
-0.043858591467142105,
-0.... | -0.088165 |
are equal, they will be shown as ``NaN``. Furthermore, if all values in an entire row / column are equal, that row / column will be omitted from the result. The remaining differences will be aligned on columns. Stack the differences on rows. .. ipython:: python df.compare(df2, align\_axis=0) Keep all original rows and ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/merging.rst | main | pandas | [
0.005890892818570137,
-0.014703258872032166,
0.005139829125255346,
-0.07604023814201355,
0.04444266855716705,
-0.10086312890052795,
-0.06862977892160416,
-0.0647943839430809,
0.007815157994627953,
0.02318969927728176,
0.06955628842115402,
0.04446203634142876,
-0.033484939485788345,
-0.0096... | -0.074189 |
.. \_indexing: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Indexing and selecting data \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* The axis labeling information in pandas objects serves many purposes: \* Identifies data (i.e. provides \*metadata\*) using known indicators, important fo... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.04910067468881607,
-0.02145887166261673,
-0.044004954397678375,
-0.03923461213707924,
0.04280100390315056,
-0.05569586902856827,
0.039023760706186295,
-0.0074156103655695915,
0.0035656646359711885,
0.029672905802726746,
0.026130028069019318,
-0.024728501215577126,
-0.07586981356143951,
... | 0.036173 |
and also ``[]`` indexing can accept a ``callable`` as indexer. See more at :ref:`Selection By Callable `. .. note:: Destructuring tuple keys into row (and column) indexes occurs \*before\* callables are applied, so you cannot return a tuple from a callable to index both rows and columns. Getting values from an object w... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.04045668616890907,
-0.04108719900250435,
-0.05274033546447754,
-0.04173494130373001,
0.01890861615538597,
-0.06681443005800247,
0.05423612520098686,
-0.034473635256290436,
-0.020922258496284485,
0.03217135742306709,
0.02787095494568348,
0.046349506825208664,
-0.05587884038686752,
-0.028... | -0.020057 |
3], index=list('abc')) dfa = df.copy() .. ipython:: python sa.b dfa.A .. ipython:: python sa.a = 5 sa dfa.A = list(range(len(dfa.index))) # ok if A already exists dfa dfa['A'] = list(range(len(dfa.index))) # use this form to create a new column dfa .. warning:: - You can use this access only if the index element is a v... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.025727614760398865,
-0.023380083963274956,
-0.04319193214178085,
0.0010499324416741729,
0.036165252327919006,
0.028351683169603348,
0.0053501371294260025,
0.0016365265473723412,
-0.04022926464676857,
0.04398868605494499,
0.05975870415568352,
0.037210267037153244,
-0.019194189459085464,
... | 0.010692 |
is \*\*not\*\* an integer position along the index.). \* A list or array of labels ``['a', 'b', 'c']``. \* A slice object with labels ``'a':'f'``. Note that contrary to usual Python slices, \*\*both\*\* the start and the stop are included, when present in the index! See :ref:`Slicing with labels `. \* A boolean array. ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.021001409739255905,
-0.004694683011621237,
-0.005321798846125603,
-0.026755928993225098,
0.04882357642054558,
-0.013001172803342342,
0.07154384255409241,
-0.07889724522829056,
-0.0010090154828503728,
-0.008218067698180676,
0.003085923846811056,
0.024401098489761353,
-0.056124407798051834,... | -0.000895 |
determine the label boundaries (inclusive), while \*step\* skips positions within that range, regardless of the index type. .. \_indexing.integer: Selection by position --------------------- pandas provides a suite of methods in order to get \*\*purely integer based indexing\*\*. The semantics follow closely Python and... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.046999502927064896,
0.04699269309639931,
-0.028485262766480446,
-0.02583977021276951,
0.026656605303287506,
-0.03874574601650238,
0.07397637516260147,
-0.01093159057199955,
-0.027418198063969612,
-0.05897664278745651,
-0.010264953598380089,
-0.013160132803022861,
-0.026225602254271507,
... | 0.065243 |
indexing to select things. .. ipython:: python dfd.iloc[[0, 2], dfd.columns.get\_loc('A')] For getting \*multiple\* indexers, using ``.get\_indexer``: .. ipython:: python dfd.iloc[[0, 2], dfd.columns.get\_indexer(['A', 'B'])] Reindexing ~~~~~~~~~~ The idiomatic way to achieve selecting potentially not-found elements is... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.021948589012026787,
-0.08364836126565933,
-0.03864670544862747,
-0.01708519645035267,
0.1022050604224205,
-0.03754160553216934,
0.0635085329413414,
-0.13117650151252747,
0.02831803448498249,
0.006190591026097536,
0.04605042189359665,
0.02910347282886505,
-0.024338658899068832,
-0.094598... | -0.050468 |
Setting with enlargement ------------------------ The ``.loc/[]`` operations can perform enlargement when setting a non-existent key for that axis. In the ``Series`` case this is effectively an appending operation. .. ipython:: python se = pd.Series([1, 2, 3]) se se[5] = 5. se A ``DataFrame`` can be enlarged on either ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.03888082876801491,
-0.07560848444700241,
-0.0068245455622673035,
-0.033084478229284286,
0.008952860720455647,
-0.0840776264667511,
-0.03005133382976055,
-0.03470136597752571,
-0.018446851521730423,
0.042990490794181824,
0.028935514390468597,
0.08185404539108276,
-0.06851159781217575,
-0... | -0.034835 |
2], [3, 4], [5, 6]], index=list('abc'), columns=['A', 'B']) s = (df['A'] > 2) s df.loc[s, 'B'] df.iloc[s.values, 1] .. \_indexing.basics.indexing\_isin: Indexing with isin ------------------ Consider the :meth:`~Series.isin` method of ``Series``, which returns a boolean vector that is true wherever the ``Series`` eleme... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
0.0281346645206213,
-0.024117212742567062,
-0.018966548144817352,
-0.04486016184091568,
0.08580633252859116,
-0.01889132708311081,
0.04607011005282402,
-0.08821821957826614,
-0.01135290414094925,
0.0065636723302304745,
-0.043995168060064316,
0.04850371554493904,
-0.03759740665555,
-0.07443... | -0.004888 |
df.copy() df2[df2 < 0] = 0 df2 ``where`` returns a modified copy of the data. .. note:: The signature for :func:`DataFrame.where` differs from :func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to ``np.where(m, df1, df2)``. .. ipython:: python df.where(df < 0, -df) == np.where(df < 0, df, -df) \*\*Alignme... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.0038173773791640997,
-0.044431328773498535,
-0.01549087930470705,
-0.03795943409204483,
0.10457273572683334,
-0.07240069657564163,
-0.0058291880413889885,
-0.07651910930871964,
-0.05550737306475639,
0.03264612704515457,
0.0697929710149765,
0.05020102113485336,
-0.06812693178653717,
0.00... | -0.047862 |
example, .. ipython:: python df = pd.DataFrame({'a': np.random.randint(5, size=5)}) df.index.name = 'a' df.query('a > 2') # uses the column 'a', not the index You can still use the index in a query expression by using the special identifier 'index': .. ipython:: python df.query('index > 2') If for some reason you have ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
0.056495457887649536,
-0.02050884999334812,
-0.020275384187698364,
0.01622186042368412,
0.0517905093729496,
-0.0634063184261322,
0.056621331721544266,
-0.009057859890162945,
0.015489650890231133,
0.04323676601052284,
0.02506233938038349,
-0.0014603629242628813,
-0.044148679822683334,
-0.10... | -0.036471 |
any operations that can be evaluated using ``numexpr`` will be. Special use of the ``==`` operator with ``list`` objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Comparing a ``list`` of values to a column using ``==``/``!=`` works similarly to ``in``/``not in``. .. ipython:: python df.query('b == ["a", ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
0.04289303719997406,
0.01688094437122345,
0.01137139368802309,
-0.030444322153925896,
0.02575111947953701,
-0.06991920620203018,
0.08996576815843582,
0.007351876236498356,
-0.025863295421004295,
0.06446541845798492,
-0.0045466250739991665,
0.012166089378297329,
0.01623293198645115,
-0.0140... | 0.040473 |
conversions: .. code-block:: python def pd\_lookup\_het(df, row\_labels, col\_labels): rows = df.index.get\_indexer(row\_labels) cols = df.columns.get\_indexer(col\_labels) sub = df.take(np.unique(cols), axis=1) sub = sub.take(np.unique(rows), axis=0) rows = sub.index.get\_indexer(row\_labels) values = sub.melt()["valu... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.010935865342617035,
0.018998347222805023,
-0.08659163117408752,
-0.05779499188065529,
0.09038662165403366,
-0.03850750997662544,
-0.047159433364868164,
-0.08022448420524597,
-0.031025832518935204,
0.01382430363446474,
0.0302360150963068,
-0.03202471509575844,
-0.11669184267520905,
-0.03... | -0.031721 |
hold missing values (``NaN``), it should be avoided if you do not want any unexpected results. For example, some operations exclude missing values implicitly. ``Index.fillna`` fills missing values with specified scalar value. .. ipython:: python idx1 = pd.Index([1, np.nan, 3, 4]) idx1 idx1.fillna(2) idx2 = pd.DatetimeI... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.04105279594659805,
-0.020870812237262726,
0.041403356939554214,
0.05801611766219139,
0.028765404596924782,
-0.04587138071656227,
0.03301491215825081,
-0.03158878907561302,
-0.005722543690353632,
-0.01679583266377449,
0.030923517420887947,
-0.013094283640384674,
-0.0661541000008583,
-0.0... | -0.000764 |
print(df) # Series with non-matching indices s3 = pd.Series([1000, 2000], index=['a', 'b']) df['nomatch'] = s3 # All values become NaN print(df) #Avoiding Confusion: #If you want positional assignment instead of index alignment: # reset the Series index to match DataFrame index df['s1\_values'] = s1.reindex(df.index) .... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/indexing.rst | main | pandas | [
-0.05061418563127518,
-0.09449425339698792,
-0.022704388946294785,
-0.060958437621593475,
0.04750678315758705,
-0.05698525160551071,
0.027064736932516098,
-0.09502410888671875,
0.03811002895236015,
0.0028176140040159225,
0.032348357141017914,
0.04084589704871178,
-0.05100690573453903,
-0.0... | 0.00338 |
.. \_10min: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* 10 minutes to pandas \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* This is a short introduction to pandas, geared mainly for new users. You can see more complex recipes in the :ref:`Cookbook`. Customarily, we import as follows: .. ipython:: python import nump... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/10min.rst | main | pandas | [
-0.039072416722774506,
0.03811987116932869,
-0.023016618564724922,
0.006863722577691078,
0.029783833771944046,
-0.050650421530008316,
-0.017872512340545654,
-0.02736865170300007,
-0.027857979759573936,
-0.04915979877114296,
0.011971313506364822,
-0.00505433464422822,
-0.1024940237402916,
-... | 0.109702 |
and yields a :class:`Series`: .. ipython:: python df["A"] If the label only contains letters, numbers, and underscores, you can alternatively use the column name attribute: .. ipython:: python df.A Passing a list of column labels selects multiple columns, which can be useful for getting a subset/rearranging: .. ipython... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/10min.rst | main | pandas | [
-0.010046626441180706,
-0.011053429916501045,
0.012958631850779057,
-0.03029906563460827,
0.09713807702064514,
0.05963338911533356,
0.049527935683727264,
-0.054472703486680984,
0.018873373046517372,
-0.015725070610642433,
0.023152295500040054,
0.02916184812784195,
-0.09824454039335251,
-0.... | -0.047003 |
the union of the index or column labels. In addition, pandas automatically broadcasts along the specified dimension and will fill unaligned labels with ``np.nan``. .. ipython:: python s = pd.Series([1, 3, 5, np.nan, 6, 8], index=dates).shift(2) s df.sub(s, axis="index") User defined functions ~~~~~~~~~~~~~~~~~~~~~~ :me... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/10min.rst | main | pandas | [
-0.00994185358285904,
-0.04950385540723801,
-0.04554588720202446,
-0.02449115924537182,
0.03206344321370125,
-0.017576536163687706,
-0.023922955617308617,
0.016019651666283607,
0.03797948732972145,
-0.013436790555715561,
0.012208754196763039,
-0.011731311678886414,
-0.029802652075886726,
-... | 0.065864 |
:meth:`~DataFrame.unstack`, which by default unstacks the \*\*last level\*\*: .. ipython:: python stacked.unstack() stacked.unstack(1) stacked.unstack(0) Pivot tables ~~~~~~~~~~~~ See the section on :ref:`Pivot Tables `. .. ipython:: python df = pd.DataFrame( { "A": ["one", "one", "two", "three"] \* 3, "B": ["A", "B", ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/10min.rst | main | pandas | [
0.000040855753468349576,
-0.07522604614496231,
-0.022575030103325844,
-0.05454893037676811,
-0.008750719018280506,
-0.0021756456699222326,
-0.011826444417238235,
-0.020848805084824562,
-0.013333478011190891,
0.06983315944671631,
0.03706710413098335,
0.010141050443053246,
0.001887682126834988... | -0.069931 |
.. ipython:: python :suppress: os.remove("foo.xlsx") Gotchas ------- If you are attempting to perform a boolean operation on a :class:`Series` or :class:`DataFrame` you might see an exception like: .. ipython:: python :okexcept: if pd.Series([False, True, False]): print("I was true") See :ref:`Comparisons` and :ref:`Go... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/10min.rst | main | pandas | [
-0.003030363004654646,
0.07682866603136063,
-0.01698097214102745,
0.030544251203536987,
0.061553955078125,
-0.040283724665641785,
0.019373832270503044,
-0.056764569133520126,
0.06887438148260117,
-0.023178718984127045,
0.06825794279575348,
0.04244910553097725,
-0.02277516759932041,
-0.0328... | -0.022732 |
.. \_window: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Windowing operations \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* pandas contains a compact set of APIs for performing windowing operations - an operation that performs an aggregation over a sliding partition of values. The API functions similarly to the ``... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
-0.06554798036813736,
-0.005692447070032358,
0.014996764250099659,
0.006188306026160717,
0.004407946020364761,
-0.015550334937870502,
-0.00313518731854856,
-0.02891438640654087,
0.03446304053068161,
-0.037538349628448486,
-0.05159221962094307,
-0.000212155282497406,
-0.04804264008998871,
-... | 0.028292 |
objects to continue the windowing calculation with the new values (i.e. online calculations). The methods on this new windowing object must call the aggregation method first to "prime" the initial state of the online calculation. Then, new :class:`DataFrame` or :class:`Series` objects can be passed in the ``update`` ar... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
0.030694469809532166,
-0.05157686397433281,
-0.004152014851570129,
-0.007135327905416489,
0.012126936577260494,
-0.06532730907201767,
-0.03427756577730179,
0.00470998790115118,
0.035935353487730026,
0.04718424752354622,
0.004954052623361349,
-0.015452558174729347,
-0.08151241391897202,
-0.... | 0.00283 |
we have the following :class:`DataFrame` .. ipython:: python use\_expanding = [True, False, True, False, True] use\_expanding df = pd.DataFrame({"values": range(5)}) df and we want to use an expanding window where ``use\_expanding`` is ``True`` otherwise a window of size 1, we can create the following ``BaseIndexer`` s... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
0.007289160508662462,
-0.017090700566768646,
0.010820555500686169,
0.03844975680112839,
0.04649273306131363,
-0.04897711053490639,
0.06029272451996803,
0.014822828583419323,
0.01576848141849041,
-0.0322846956551075,
-0.0657193660736084,
0.016088180243968964,
-0.08785313367843628,
0.0149461... | 0.05804 |
behavior in each case: \* two :class:`Series`: compute the statistic for the pairing. \* :class:`DataFrame`/:class:`Series`: compute the statistics for each column of the DataFrame with the passed Series, thus returning a DataFrame. \* :class:`DataFrame`/:class:`DataFrame`: by default compute the statistic for matching... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
-0.051995329558849335,
-0.041105058044195175,
-0.024526765570044518,
0.009629229083657265,
0.045190855860710144,
-0.007233934476971626,
-0.047555435448884964,
-0.057107798755168915,
0.005407629534602165,
-0.0014514002250507474,
0.029907772317528725,
0.01888236775994301,
-0.06016385555267334,... | -0.040355 |
+ ... + (1 - \alpha)^t x\_{0}}{1 + (1 - \alpha) + (1 - \alpha)^2 + ... + (1 - \alpha)^t} When ``adjust=False`` is specified, moving averages are calculated as .. math:: y\_0 &= x\_0 \\ y\_t &= (1 - \alpha) y\_{t-1} + \alpha x\_t, which is equivalent to using weights .. math:: w\_i = \begin{cases} \alpha (1 - \alpha)^i ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
-0.07538418471813202,
-0.05267905443906784,
0.030458809807896614,
0.01145812775939703,
0.023940593004226685,
-0.07088306546211243,
0.044398218393325806,
0.01766301319003105,
0.07870420068502426,
0.03125916048884392,
0.0030997993890196085,
-0.025293011218309402,
0.05267518013715744,
-0.0247... | 0.127526 |
ExponentialMovingWindow also has an ``ignore\_na`` argument, which determines how intermediate null values affect the calculation of the weights. When ``ignore\_na=False`` (the default), weights are calculated based on absolute positions, so that intermediate null values affect the result. When ``ignore\_na=True``, wei... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/window.rst | main | pandas | [
-0.08210528641939163,
-0.012197254225611687,
-0.0002956238458864391,
0.01684408076107502,
-0.0334240086376667,
-0.12229499220848083,
0.04700394719839096,
-0.02890336513519287,
0.07153712213039398,
0.038475729525089264,
0.03641895204782486,
-0.1442229002714157,
0.03408549726009369,
-0.00225... | 0.030802 |
.. \_categorical: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Categorical data \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* This is an introduction to pandas categorical data type, including a short comparison with R's ``factor``. ``Categoricals`` are a pandas data type corresponding to categorical variables in statistics. A cat... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.11184284090995789,
-0.017168737947940826,
0.005089474841952324,
-0.021828802302479744,
-0.003682393115013838,
-0.015087543986737728,
-0.06810551136732101,
-0.027631592005491257,
-0.032299164682626724,
0.004035427700728178,
0.05289723351597786,
-0.01314298715442419,
-0.06368952244520187,
... | -0.030476 |
list("abca"), "B": list("bccd")}) df\_cat = df.astype("category") df\_cat.dtypes This conversion is likewise done column by column: .. ipython:: python df\_cat["A"] df\_cat["B"] Controlling behavior ~~~~~~~~~~~~~~~~~~~~ In the examples above where we passed ``dtype='category'``, we used the default behavior: 1. Categor... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.028487108647823334,
-0.024740062654018402,
-0.022768860682845116,
0.0007192306802608073,
-0.03468727692961693,
-0.002154566580429673,
-0.00036070492933504283,
-0.038365501910448074,
0.0008990662754513323,
0.02397785894572735,
0.018979037180542946,
-0.03886937350034714,
-0.05705601349472999... | -0.030533 |
pd.Categorical(np.array([], dtype=float)) c2.dtype == c3.dtype Description ----------- Using :meth:`~DataFrame.describe` on categorical data will produce similar output to a ``Series`` or ``DataFrame`` of type ``string``. .. ipython:: python cat = pd.Categorical(["a", "c", "c", np.nan], categories=["b", "a", "c"]) df =... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.07702284306287766,
-0.03490464389324188,
0.0031127771362662315,
-0.02971239760518074,
-0.015020141378045082,
-0.005386494565755129,
-0.051331132650375366,
-0.05060378462076187,
0.026028551161289215,
-0.012470290996134281,
0.02817354165017605,
-0.03440989926457405,
-0.09999168664216995,
0... | -0.039967 |
"b", "c", "a"]).astype(CategoricalDtype(ordered=True)) s = s.sort\_values() s s.min(), s.max() You can set categorical data to be ordered by using ``as\_ordered()`` or unordered by using ``as\_unordered()``. These will by default return a \*new\* object. .. ipython:: python s.cat.as\_ordered() s.cat.as\_unordered() Sor... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.0735524594783783,
-0.022468212991952896,
0.02517368271946907,
-0.0055139255709946156,
-0.11403229087591171,
0.01920107565820217,
-0.03207538276910782,
-0.021280210465192795,
-0.0042306846007704735,
0.004477234091609716,
0.00458992924541235,
0.05427204445004463,
-0.03162084519863129,
-0.0... | -0.023485 |
.. ipython:: python cat == cat\_base cat == np.array([1, 2, 3]) cat == 2 This doesn't work because the categories are not the same: .. ipython:: python try: cat > cat\_base2 except TypeError as e: print("TypeError:", str(e)) If you want to do a "non-equality" comparison of a categorical series with a list-like object w... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.07704579085111618,
0.008073161356151104,
0.03869534656405449,
0.014197616837918758,
-0.024914219975471497,
-0.048557110130786896,
-0.07086225599050522,
-0.05596843734383583,
0.009656133130192757,
-0.021197447553277016,
-0.01021772250533104,
-0.007985199801623821,
-0.06408286839723587,
-0... | -0.008343 |
``s.cat.categories`` are of an appropriate type: .. ipython:: python str\_s = pd.Series(list("aabb")) str\_cat = str\_s.astype("category") str\_cat str\_cat.str.contains("a") date\_s = pd.Series(pd.date\_range("1/1/2015", periods=5)) date\_cat = date\_s.astype("category") date\_cat date\_cat.dt.day .. note:: The return... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
-0.00439746817573905,
0.024623636156320572,
-0.008438668213784695,
0.08916947990655899,
-0.06665738672018051,
-0.028002159669995308,
-0.0367930643260479,
-0.013861417770385742,
0.014434338547289371,
-0.04986068978905678,
0.04285794124007225,
-0.006550318095833063,
-0.10946647822856903,
-0.... | -0.042898 |
| category (object) | category (object) | False | object (dtype is inferred) | +-------------------+------------------------+----------------------+-----------------------------+ | category (int) | category (float) | False | float (dtype is inferred) | +-------------------+------------------------+---------------------... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.027160564437508583,
0.023950014263391495,
-0.03639204055070877,
0.04116695001721382,
-0.07150472700595856,
-0.01864946261048317,
0.009191375225782394,
-0.006671554874628782,
-0.005239346995949745,
-0.01616116799414158,
-0.009484670124948025,
-0.17516426742076874,
-0.04943704977631569,
0.... | 0.075475 |
be included in the Categorical's ``categories``, only in the ``values``. Instead, it is understood that NaN is different, and is always a possibility. When working with the Categorical's ``codes``, missing values will always have a code of ``-1``. .. ipython:: python s = pd.Series(["a", "b", np.nan, "a"], dtype="catego... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.019182056188583374,
-0.01506150420755148,
-0.0073995208367705345,
-0.017647026106715202,
-0.011256410740315914,
-0.027477923780679703,
-0.035592757165431976,
-0.03307813033461571,
-0.005290459841489792,
-0.018797434866428375,
0.08237127959728241,
-0.05023328214883804,
-0.022883238270878792... | -0.030614 |
row: type(row["cats"]), axis=1) df.apply(lambda col: col.dtype, axis=0) Categorical index ~~~~~~~~~~~~~~~~~ ``CategoricalIndex`` is a type of index that is useful for supporting indexing with duplicates. This is a container around a ``Categorical`` and allows efficient indexing and storage of an index with a large numb... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/categorical.rst | main | pandas | [
0.08029095083475113,
-0.02620042860507965,
0.02366010658442974,
-0.03869511932134628,
-0.04029298201203346,
0.027582524344325066,
0.011461388319730759,
-0.07665868103504181,
0.02581791765987873,
0.015870623290538788,
0.022344669327139854,
0.07729603350162506,
-0.07272236794233322,
-0.00807... | -0.037637 |
.. \_timedeltas: {{ header }} .. \_timedeltas.timedeltas: \*\*\*\*\*\*\*\*\*\*\* Time deltas \*\*\*\*\*\*\*\*\*\*\* Timedeltas are differences in times, expressed in difference units, e.g. days, hours, minutes, seconds. They can be both positive and negative. ``Timedelta`` is a subclass of ``datetime.timedelta``, and b... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timedeltas.rst | main | pandas | [
-0.03636625036597252,
0.06612656265497208,
0.011109145358204842,
0.0004634090873878449,
-0.07308696955442429,
-0.0808635726571083,
-0.04328274354338646,
0.01659356988966465,
-0.019953018054366112,
-0.02710762619972229,
0.028002876788377762,
-0.09803729504346848,
-0.0472998209297657,
0.0465... | 0.050614 |
1, 3, 5) - s datetime.timedelta(minutes=5) + s ``min, max`` and the corresponding ``idxmin, idxmax`` operations are supported on frames: .. ipython:: python A = s - pd.Timestamp("20120101") - pd.Timedelta("00:05:05") B = s - pd.Series(pd.date\_range("2012-1-2", periods=3, freq="D")) df = pd.DataFrame({"A": A, "B": B}) ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timedeltas.rst | main | pandas | [
-0.0012303342809900641,
-0.03825937211513519,
0.012805222533643246,
-0.09239575266838074,
0.007886895909905434,
-0.007674135267734528,
-0.023922497406601906,
-0.007859187200665474,
0.023530855774879456,
-0.006869079079478979,
0.005938468500971794,
0.03796174377202988,
-0.03818998858332634,
... | -0.00156 |
ipython:: python pd.Timedelta( days=6, minutes=50, seconds=3, milliseconds=10, microseconds=10, nanoseconds=12 ).isoformat() .. \_ISO 8601 Duration: https://en.wikipedia.org/wiki/ISO\_8601#Durations .. \_timedeltas.index: TimedeltaIndex -------------- To generate an index with time delta, you can use either the :class:... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timedeltas.rst | main | pandas | [
0.004069613292813301,
0.048163898289203644,
-0.011032987385988235,
0.030574139207601547,
-0.05287444218993187,
-0.03312745317816734,
-0.032287877053022385,
-0.0005315938615240157,
-0.013747090473771095,
-0.05723591521382332,
0.051382556557655334,
-0.10735909640789032,
-0.11378348618745804,
... | 0.052667 |
.. \_groupby: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Group by: split-apply-combine \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* By "group by" we are referring to a process involving one or more of the following steps: \* \*\*Splitting\*\* the data into groups based on some... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.09756170958280563,
0.0678657740354538,
0.05675816163420677,
-0.00480273924767971,
0.030689597129821777,
-0.03677699342370033,
0.02737935446202755,
-0.02373816817998886,
-0.050455186516046524,
0.06206720694899559,
0.02471129409968853,
-0.1066511869430542,
0.046640023589134216,
-0.0858262... | 0.051447 |
``groupby`` may refer to either a column or an index level. If a string matches both a column name and an index level name, a ``ValueError`` will be raised. .. ipython:: python df = pd.DataFrame( { "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"], "B": ["one", "one", "two", "three", "two", "two", "one", "t... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.03481816127896309,
-0.04891614243388176,
-0.014742327854037285,
0.02482827939093113,
0.061110761016607285,
-0.04492532089352608,
0.011844991706311703,
-0.0513358935713768,
0.034090831875801086,
-0.0018043762538582087,
0.04657064005732536,
-0.026630550622940063,
-0.02886732667684555,
-0.... | -0.041683 |
function on the GroupBy object returns the number of groups, which is the same as the length of the ``groups`` dictionary: .. ipython:: python grouped = df.groupby(["A", "B"]) grouped.groups len(grouped) .. \_groupby.tabcompletion: ``GroupBy`` will tab complete column names, GroupBy operations, and other attributes: ..... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.07601841539144516,
-0.008362841792404652,
0.008738785982131958,
0.04167131334543228,
0.007803856395184994,
-0.03561950847506523,
0.0511246956884861,
-0.09501758217811584,
-0.05815127119421959,
0.02630784548819065,
0.04184753820300102,
-0.03373394161462784,
-0.09065525978803635,
-0.026009... | -0.069936 |
this method avoids recomputing the internal grouping information derived from the passed key. You can also include the grouping columns if you want to operate on them. .. ipython:: python grouped[["A", "B"]].sum() .. note:: The ``groupby`` operation in pandas drops the ``name`` field of the columns Index object after t... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.008011377416551113,
0.011403840035200119,
-0.04930233582854271,
0.01092320866882801,
0.034705691039562225,
-0.04191877320408821,
0.05743764340877533,
-0.06698337197303772,
-0.0004988310975022614,
0.0001138566731242463,
0.059445373713970184,
0.007826399989426136,
-0.06127103045582771,
-0.... | -0.037722 |
values are the sizes of each group. .. ipython:: python grouped = df.groupby(["A", "B"]) grouped.size() While the :meth:`.DataFrameGroupBy.describe` method is not itself a reducer, it can be used to conveniently produce a collection of summary statistics about each of the groups. .. ipython:: python grouped.describe() ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.06518430262804031,
-0.027181357145309448,
-0.011806491762399673,
-0.0020476041827350855,
0.008978188037872314,
-0.0021259780041873455,
-0.014743109233677387,
-0.0000729596649762243,
0.04696819186210632,
-0.03198011964559555,
0.015156585723161697,
-0.015496307983994484,
-0.02094845473766327... | -0.032398 |
"std": "baz"}) ) Or, you can simply pass a list of tuples each with the name of the new column and the aggregate function: .. ipython:: python ( grouped["C"] .agg([("foo", "sum"), ("bar", "mean"), ("baz", "std")]) ) For a grouped ``DataFrame``, you can rename in a similar manner: By chaining ``rename`` operation, .. ip... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.008434632793068886,
-0.012509578838944435,
0.023829497396945953,
0.01936357468366623,
-0.09991126507520676,
-0.016757696866989136,
0.020483067259192467,
0.01934489794075489,
0.01904255710542202,
0.0024551197420805693,
0.011251838877797127,
0.019695142284035683,
-0.062427375465631485,
-0... | 0.007243 |
ipython:: python result = speeds.copy() result["cumsum"] = grouped.cumsum() result["diff"] = grouped.diff() result Built-in transformation methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following methods on GroupBy act as transformations. .. csv-table:: :header: "Method", "Description" :widths: 20, 80 :meth:`~.DataFrameGr... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.013076185248792171,
-0.00688836770132184,
0.008545187301933765,
-0.04625267907977104,
-0.051264189183712006,
-0.06492793560028076,
0.007506476249545813,
0.02581561915576458,
-0.01346807461231947,
-0.009663037955760956,
-0.00990030076354742,
-0.12890766561031342,
0.037112023681402206,
-0... | -0.015285 |
Data grouped = ts.groupby(lambda x: x.year) grouped.mean() grouped.std() # Transformed Data grouped\_trans = transformed.groupby(lambda x: x.year) grouped\_trans.mean() grouped\_trans.std() We can also visually compare the original and transformed data sets. .. ipython:: python compare = pd.DataFrame({"Original": ts, "... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.0007246094755828381,
0.032676275819540024,
0.07424338161945343,
-0.0444880835711956,
0.010839168913662434,
-0.03260166198015213,
-0.05683194845914841,
-0.05780225992202759,
-0.01029790285974741,
-0.009389244019985199,
-0.006392586976289749,
-0.026804247871041298,
-0.005109873134642839,
... | -0.06931 |
python speeds.groupby("class")[["order", "max\_speed"]].nth(1) Built-in filtrations ~~~~~~~~~~~~~~~~~~~~ The following methods on GroupBy act as filtrations. All these methods have an efficient, GroupBy-specific, implementation. .. csv-table:: :header: "Method", "Description" :widths: 20, 80 :meth:`~.DataFrameGroupBy.h... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.012738014571368694,
0.026300497353076935,
0.012871340848505497,
-0.057401832193136215,
0.036986093968153,
-0.08143551647663116,
0.038902487605810165,
-0.05072960630059242,
-0.019743936136364937,
0.014679058454930782,
-0.014545805752277374,
-0.04789416491985321,
-0.005279149394482374,
-0.... | -0.047696 |
to :ref:`groupby.aggregate.agg`, the resulting dtype will reflect that of the apply function. If the results from different groups have different dtypes, then a common dtype will be determined in the same way as ``DataFrame`` construction. Control grouped column(s) placement with ``group\_keys`` ~~~~~~~~~~~~~~~~~~~~~~~... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.0374678373336792,
-0.07663789391517639,
0.002160086529329419,
-0.006175603251904249,
0.029944712296128273,
-0.05096554011106491,
0.0555642805993557,
-0.04414942488074303,
0.006086545065045357,
-0.01340505387634039,
0.03459832817316055,
-0.019703634083271027,
-0.026719583198428154,
-0.07... | -0.014711 |
end of the result in order. .. ipython:: python days = pd.Categorical( values=["Wed", "Mon", "Thu", "Mon", "Wed", "Sat"], categories=["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], ) data = pd.DataFrame( { "day": days, "workers": [3, 4, 1, 4, 2, 2], } ) data data.groupby("day", observed=False, sort=True).sum() data.... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.09045296907424927,
0.027918070554733276,
0.057731229811906815,
0.07408826053142548,
-0.02487480454146862,
-0.006046043708920479,
0.015484091825783253,
-0.0941493883728981,
-0.08064422011375427,
0.0076041799038648605,
0.055348627269268036,
-0.06920640915632248,
-0.09808151423931122,
0.000... | -0.053955 |
4th, and last date index for each month df.groupby([df.index.year, df.index.month]).nth([0, 3, -1]) You may also use slices or lists of slices. .. ipython:: python df.groupby([df.index.year, df.index.month]).nth[1:] df.groupby([df.index.year, df.index.month]).nth[1:, :-1] Enumerate group items ~~~~~~~~~~~~~~~~~~~~~ To ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
0.054590895771980286,
-0.0491645522415638,
-0.001771418610587716,
-0.061700109392404556,
0.003955810330808163,
0.050450243055820465,
-0.008887720294296741,
-0.12813988327980042,
0.006567992735654116,
0.05384470149874687,
0.09352433681488037,
0.007342255208641291,
-0.05426887050271034,
-0.0... | -0.072683 |
step in processing, when the relationships between the group rows are more important than their content, or as input to an algorithm which only accepts the integer encoding. (For more information about support in pandas for full categorical data, see the :ref:`Categorical introduction ` and the :ref:`API documentation ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/groupby.rst | main | pandas | [
-0.04933519661426544,
-0.06752459704875946,
-0.008881226181983948,
0.002544129965826869,
0.009900118224322796,
0.003575447713956237,
-0.025892946869134903,
-0.0951448604464531,
0.015322022140026093,
0.013302796520292759,
-0.007452068384736776,
-0.00221350253559649,
-0.029426727443933487,
-... | -0.005856 |
.. \_pyarrow: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* PyArrow Functionality \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* pandas can utilize `PyArrow `\_\_ to extend functionality and improve the performance of various APIs. This includes: \* More extensive `data types `\_\_ compared to NumPy \* Missing da... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/pyarrow.rst | main | pandas | [
-0.04204612597823143,
-0.0789087563753128,
-0.037181638181209564,
0.003319806419312954,
0.004189754836261272,
-0.07392565906047821,
-0.057185955345630646,
-0.0058320979587733746,
-0.016948606818914413,
-0.023808347061276436,
0.06497949361801147,
0.052375052124261856,
-0.05548013001680374,
... | 0.010421 |
provide an ``engine`` keyword that can dispatch to PyArrow to accelerate reading from an IO source. \* :func:`read\_csv` \* :func:`read\_feather` \* :func:`read\_json` \* :func:`read\_orc` \* :func:`read\_parquet` \* :func:`read\_table` (experimental) .. ipython:: python import io data = io.StringIO("""a,b,c 1,2.5,True... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/pyarrow.rst | main | pandas | [
-0.06253670901060104,
-0.04468247666954994,
-0.0705258846282959,
0.03428532928228378,
-0.05111599341034889,
-0.11918043345212936,
0.023447757586836815,
0.008862561546266079,
-0.03990074247121811,
0.0012441459111869335,
0.03672436252236366,
0.027596384286880493,
-0.058418188244104385,
-0.02... | 0.070254 |
.. \_enhancingperf: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Enhancing performance \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* In this part of the tutorial, we will investigate how to speed up certain functions operating on pandas :class:`DataFrame` using Cython, Numba and :func:`pandas.eval`. Generally, ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.07469985634088516,
-0.0017587871989235282,
-0.06465498358011246,
-0.05060861259698868,
0.056001633405685425,
-0.1041800007224083,
-0.01423709001392126,
-0.0015941995661705732,
-0.02889109216630459,
-0.02799566462635994,
0.022744515910744667,
-0.011817689053714275,
-0.06672563403844833,
... | -0.0185 |
- a) / N ...: for i in range(N): ...: s += f\_typed(a + i \* dx) ...: return s \* dx ...: .. ipython:: python %timeit df.apply(lambda x: integrate\_f\_typed(x["a"], x["b"], x["N"]), axis=1) Annotating the functions with C types yields an over ten times performance improvement compared to the original Python implementat... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.022362500429153442,
-0.02832970581948757,
-0.061581142246723175,
-0.0148270009085536,
-0.01856340281665325,
-0.05623573437333107,
0.03131882846355438,
-0.014002188108861446,
-0.02679225243628025,
0.008106685243546963,
-0.04405234381556511,
0.03484020754694939,
-0.0312060359865427,
0.015... | 0.0778 |
you to write a pure Python function which can be JIT compiled to native machine instructions, similar in performance to C, C++ and Fortran, by decorating your function with ``@jit``. Numba works by generating optimized machine code using the LLVM compiler infrastructure at import time, runtime, or statically (using the... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.11253536492586136,
-0.0200035497546196,
-0.036304932087659836,
0.031978730112314224,
-0.04521603137254715,
-0.14031514525413513,
-0.05413547530770302,
0.07598475366830826,
0.01204000785946846,
-0.012636834755539894,
-0.017778007313609123,
0.02233150228857994,
-0.03141510859131813,
-0.05... | 0.1016 |
representations with :meth:`Series.to\_numpy`. .. code-block:: python import numba @numba.jit def f\_plain(x): return x \* (x - 1) @numba.jit def integrate\_f\_numba(a, b, N): s = 0 dx = (b - a) / N for i in range(N): s += f\_plain(a + i \* dx) return s \* dx @numba.jit def apply\_integrate\_f\_numba(col\_a, col\_b, co... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.06197286397218704,
-0.06360277533531189,
-0.05658756196498871,
-0.04351711645722389,
-0.05525539070367813,
-0.06964752823114395,
-0.03411201015114784,
0.0190550796687603,
-0.015277874656021595,
-0.002806692849844694,
-0.03172754496335983,
-0.030479121953248978,
0.008787069469690323,
0.0... | 0.078241 |
df4 or not df\_bool`` \* ``list`` and ``tuple`` literals, e.g., ``[1, 2]`` or ``(1, 2)`` \* Attribute access, e.g., ``df.a`` \* Subscript expressions, e.g., ``df[0]`` \* Simple variable evaluation, e.g., ``pd.eval("df")`` (this is not very useful) \* Math functions: ``sin``, ``cos``, ``exp``, ``log``, ``expm1``, ``log1... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
0.018629705533385277,
-0.037328511476516724,
-0.013240592554211617,
-0.04437839984893799,
0.02927633747458458,
-0.06404639035463333,
0.05774165317416191,
0.02390403486788273,
0.014759814366698265,
0.09852457791566849,
0.07014766335487366,
-0.0217535849660635,
-0.004506037570536137,
0.06728... | 0.047167 |
to be installed. The ``'python'`` engine is generally \*not\* useful except for testing other evaluation engines against it. You will achieve \*\*no\*\* performance benefits using :func:`~pandas.eval` with ``engine='python'`` and may incur a performance hit. .. ipython:: python %timeit df1 + df2 + df3 + df4 .. ipython:... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.02030106633901596,
-0.007672636304050684,
-0.06196257099509239,
-0.004894050769507885,
0.12950916588306427,
-0.12279753386974335,
-0.022084489464759827,
-0.0022542080841958523,
-0.021054068580269814,
-0.035261888056993484,
-0.0017759447218850255,
-0.03876626491546631,
-0.06955388188362122... | -0.036151 |
image:: ../\_static/eval-perf.png You will only see the performance benefits of using the ``numexpr`` engine with :func:`pandas.eval` if your :class:`~pandas.DataFrame` has more than approximately 100,000 rows. Even then, the benefit depends on expression complexity: the more operations in the expression, the greater t... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/enhancingperf.rst | main | pandas | [
-0.055307187139987946,
-0.02912409044802189,
-0.04863604158163071,
-0.04787634685635567,
0.1229918971657753,
-0.09462076425552368,
-0.01218605786561966,
0.0211636945605278,
0.04839760810136795,
0.02593408338725567,
-0.014723701402544975,
-0.025516003370285034,
-0.03996819257736206,
0.02173... | 0.07431 |
.. \_duplicates: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Duplicate Labels \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* :class:`Index` objects are not required to be unique; you can have duplicate row or column labels. This may be a bit confusing at first. If you're familiar with SQL, you know that row labels are similar to a primary key ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/duplicates.rst | main | pandas | [
-0.059295590966939926,
-0.047963157296180725,
-0.03463078662753105,
-0.044337138533592224,
-0.019117018207907677,
-0.03147793933749199,
0.08349031209945679,
-0.06697509437799454,
0.010881812311708927,
0.0027697531040757895,
0.071383535861969,
0.04809528961777687,
0.010428046807646751,
-0.0... | 0.038918 |
both row and column labels for a :class:`DataFrame` .. ipython:: python :okexcept: pd.DataFrame([[0, 1, 2], [3, 4, 5]], columns=["A", "B", "C"],).set\_flags( allows\_duplicate\_labels=False ) This attribute can be checked or set with :attr:`~DataFrame.flags.allows\_duplicate\_labels`, which indicates whether that objec... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/duplicates.rst | main | pandas | [
0.054048389196395874,
-0.016857538372278214,
-0.09301261603832245,
-0.0400221161544323,
0.04633224010467529,
0.010733609087765217,
0.06573318690061569,
-0.11709233373403549,
0.006770135369151831,
-0.002693560440093279,
0.0726172998547554,
0.021589482203125954,
-0.020431222394108772,
-0.022... | -0.045672 |
.. \_migration\_guides: {{ header }} ================ Migration Guides ================ For large changes that are difficult or impossible to deprecate in a user-friendly manner, pandas will implement the changes under the ``future`` configuration. This section goes into detail for each of these changes. .. \_copy\_on\... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.11302334815263748,
-0.05819899961352348,
0.01864062249660492,
-0.014089321717619896,
0.09905599802732468,
-0.11432323604822159,
-0.040306415408849716,
-0.039944663643836975,
-0.05402636155486107,
0.04823853075504303,
0.07322187721729279,
0.03307296708226204,
-0.07349839061498642,
-0.047... | 0.026166 |
relying on the change propagating back to the parent :class:`DataFrame`. This statement can be rewritten into a single statement with ``loc`` or ``iloc`` if this behavior is necessary. :meth:`DataFrame.where` is another suitable alternative for this case. Updating a column selected from a :class:`DataFrame` with an inp... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.014839238487184048,
-0.004012689460068941,
0.07377450913190842,
-0.01516855787485838,
0.06497865170240402,
-0.07307491451501846,
-0.02088393270969391,
-0.03889232501387596,
0.0077963098883628845,
0.08653251826763153,
0.028888758271932602,
0.06985205411911011,
-0.1027359887957573,
-0.070... | -0.035446 |
python df = pd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]}) view = df[:] df.iloc[0, 0] = 100 df view .. \_copy\_on\_write\_chained\_assignment: Chained Assignment ------------------ Chained assignment references a technique where an object is updated through two subsequent indexing operations, e.g. .. code-block:: i... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.05422430858016014,
-0.07057158648967743,
0.012997734360396862,
-0.02961673215031624,
-0.0006051052478142083,
-0.0812961533665657,
-0.00048701520427130163,
-0.07288184016942978,
0.01589043065905571,
0.08241011202335358,
0.06000639125704765,
0.04792347922921181,
-0.06833487749099731,
-0.0... | -0.02072 |
.. \_string\_migration\_guide: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* The new string data type \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* The upcoming pandas 3.0 release introduces a new, default string data type. This will most likely cause some work when upgrading to pandas 3.0, and this page provides... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.03531009331345558,
-0.061718735843896866,
0.019907578825950623,
-0.05237055569887161,
0.041838012635707855,
-0.10834310948848724,
-0.019788313657045364,
-0.0152864009141922,
-0.07583072036504745,
0.03824203833937645,
0.043266456574201584,
-0.038200028240680695,
-0.16167040169239044,
-0.... | -0.031914 |
will raise an error if you try to store a non-string value in it (see below for more details). Missing values with the new string dtype are always represented as ``NaN`` (``np.nan``), and the missing value behavior is similar to other default dtypes. This new string dtype should otherwise behave the same as the existin... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.05663766339421272,
-0.023066524416208267,
-0.050540223717689514,
-0.03959301486611366,
-0.06870952993631363,
-0.05256851017475128,
0.003461093408986926,
0.03725948557257652,
-0.0032918171491473913,
-0.0038488944992423058,
0.07111683487892151,
-0.028341442346572876,
-0.04454464092850685,
... | 0.031906 |
works for pandas 3.x, it raises an error in pandas 2.x. As an alternative, you can select both ``object`` (for pandas 2.x) and ``"string"`` (for pandas 3.x; which will also select the default ``str`` dtype and does not error on pandas 2.x): .. code-block:: python # can use ``include=["str"]`` for pandas >= 3 >>> df.sel... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.03401300683617592,
-0.06878488510847092,
-0.025802472606301308,
-0.011511269956827164,
0.09473292529582977,
-0.09133364260196686,
0.012973730452358723,
-0.007266786880791187,
-0.009880390018224716,
0.012907460331916809,
0.0687134638428688,
-0.06507930159568787,
-0.0899386778473854,
-0.0... | 0.012797 |
0 ☀ 1 \ud83d dtype: object However, when using the string dtype using ``pyarrow`` under the hood, this can only store valid unicode data, and otherwise it will raise an error: .. code-block:: python >>> ser = pd.Series(["\u2600", "\ud83d"]) --------------------------------------------------------------------------- Uni... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.0569438561797142,
-0.06060042232275009,
-0.0660981684923172,
-0.032297976315021515,
-0.10357766598463058,
-0.07871484011411667,
-0.013589637354016304,
0.028397541493177414,
-0.012295478954911232,
-0.031463880091905594,
0.009099901653826237,
-0.040272634476423264,
-0.08160991966724396,
0... | -0.073681 |
a Series with string data would generally raise an error, except when the Series was empty or contained only a single string (potentially with missing values): .. code-block:: python >>> ser = pd.Series(["a", None], dtype=object) >>> ser.prod() 'a' When the Series contains multiple strings, it will raise a ``TypeError`... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/migration.rst | main | pandas | [
-0.0700967013835907,
-0.041460126638412476,
-0.013073710724711418,
-0.004405494779348373,
-0.031823594123125076,
-0.056500524282455444,
-0.032167430967092514,
0.02065454050898552,
0.07042773067951202,
-0.03016021102666855,
0.030719272792339325,
-0.011565245687961578,
-0.07202600687742233,
... | -0.000828 |
.. \_timeseries: {{ header }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Time series / date functionality \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* pandas contains extensive capabilities and features for working with time series data for all domains. Using the NumPy ``dateti... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.07262347638607025,
-0.012018483132123947,
-0.014740923419594765,
-0.001180511200800538,
0.0037016693968325853,
-0.055374305695295334,
-0.06598176807165146,
0.019346505403518677,
0.0015819198451936245,
0.0053039309568703175,
-0.027797160670161247,
-0.035285867750644684,
-0.1133728176355362... | 0.068165 |
means using the points in time. .. ipython:: python import datetime pd.Timestamp(datetime.datetime(2012, 5, 1)) pd.Timestamp("2012-05-01") pd.Timestamp(2012, 5, 1) However, in many cases it is more natural to associate things like change variables with a time span instead. The span represented by ``Period`` can be spec... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.06375687569379807,
0.028590401634573936,
0.046734027564525604,
0.02996121719479561,
0.033513057976961136,
-0.00951183121651411,
-0.021924233064055443,
0.025580355897545815,
0.01493852585554123,
-0.04328818991780281,
0.019429000094532967,
0.016168903559446335,
-0.040579572319984436,
-0.0... | 0.033554 |
{"year": [2015, 2016], "month": [2, 3], "day": [4, 5], "hour": [2, 3]} ) pd.to\_datetime(df) You can pass only the columns that you need to assemble. .. ipython:: python pd.to\_datetime(df[["year", "month", "day"]]) ``pd.to\_datetime`` looks for standard designations of the datetime component in the column names, inclu... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
0.00860429834574461,
0.009556585922837257,
-0.014077789150178432,
0.042804550379514694,
0.024460582062602043,
-0.07812371104955673,
-0.05763356760144234,
0.03337797522544861,
-0.04351801425218582,
0.005850368645042181,
0.029779482632875443,
-0.07866128534078598,
-0.09829726070165634,
0.004... | -0.006598 |
we often need a very long index with a large number of timestamps. If we need timestamps on a regular frequency, we can use the :func:`date\_range` and :func:`bdate\_range` functions to create a ``DatetimeIndex``. The default frequency for ``date\_range`` is a \*\*calendar day\*\* while the default for ``bdate\_range``... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.0064109694212675095,
0.014327297918498516,
0.012360915541648865,
0.05759206786751747,
-0.020923621952533722,
0.004190064966678619,
-0.035585422068834305,
-0.007024343125522137,
-0.01532210037112236,
-0.04809949919581413,
-0.01755240559577942,
-0.03282603621482849,
-0.07679859548807144,
... | 0.034808 |
of these methods may have unexpected or incorrect behavior if the dates are unsorted. ``DatetimeIndex`` can be used like a regular index and offers all of its intelligent functionality like selection, slicing, etc. .. ipython:: python rng = pd.date\_range(start, end, freq="BME") ts = pd.Series(np.random.randn(len(rng))... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.043957240879535675,
-0.01757221668958664,
0.04827304556965828,
0.08653470128774643,
0.02740163914859295,
-0.019812095910310745,
-0.043305251747369766,
0.014307324774563313,
0.005582918878644705,
-0.011060310527682304,
-0.04660515859723091,
0.02847081609070301,
-0.10653361678123474,
-0.0... | 0.04091 |
cannot be less precise than day. .. ipython:: python series\_monthly = pd.Series( [1, 2, 3], pd.DatetimeIndex(["2011-12", "2012-01", "2012-02"]) ) series\_monthly.index.resolution series\_monthly["2011-12"] # returns Series Exact indexing ~~~~~~~~~~~~~~ As discussed in previous section, indexing a ``DatetimeIndex`` wit... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.05119273066520691,
0.040003444999456406,
0.031587325036525726,
0.06928018480539322,
0.014258349314332008,
-0.08423537015914917,
-0.014390715397894382,
0.03841988742351532,
0.04335322231054306,
-0.05878440663218498,
-0.01945820078253746,
0.011561366729438305,
-0.056213416159152985,
-0.00... | 0.055062 |
\* the frequency of a :class:`Period` or :class:`PeriodIndex` These frequency strings map to a :class:`DateOffset` object and its subclasses. A :class:`DateOffset` is similar to a :class:`Timedelta` that represents a duration of time but follows specific calendar duration rules. For example, a :class:`Timedelta` day wi... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.016825459897518158,
0.06472433358430862,
-0.006818672642111778,
0.014118771068751812,
-0.06507089734077454,
-0.04287360608577728,
-0.04441886022686958,
0.0270859207957983,
-0.007384348660707474,
-0.022962698712944984,
0.05055982246994972,
-0.0552201084792614,
0.009394080378115177,
0.009... | 0.101955 |
the date to the closest offset date (Monday) offset.rollforward(ts) # Date is brought to the closest offset date first and then the hour is added ts + offset These operations preserve time (hour, minute, etc) information by default. To reset time to midnight, use :meth:`normalize` before or after applying the operation... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.014476343058049679,
0.0438307449221611,
-0.01989024132490158,
0.007114753592759371,
-0.02330843359231949,
-0.03203003108501434,
-0.05796041712164879,
0.08016898483037949,
-0.05120895057916641,
-0.046297259628772736,
0.027192410081624985,
-0.012667233124375343,
-0.004788216203451157,
-0.... | -0.030974 |
offset pd.date\_range(start="20100101", end="20120101", freq=bmth\_us) .. note:: The frequency string 'C' is used to indicate that a CustomBusinessDay DateOffset is used, it is important to note that since CustomBusinessDay is a parameterised type, instances of CustomBusinessDay may differ and this is not detectable fr... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.027102665975689888,
0.0633525624871254,
-0.012264270335435867,
0.015469462610781193,
-0.09828682243824005,
0.02944488264620304,
0.00111957301851362,
0.053759243339300156,
-0.01938134804368019,
-0.07337061315774918,
0.02222481556236744,
-0.10666102170944214,
-0.04326239600777626,
-0.0454... | 0.035451 |
allows you to specify arbitrary holidays. ``CustomBusinessHour`` works as the same as ``BusinessHour`` except that it skips specified custom holidays. .. ipython:: python from pandas.tseries.holiday import USFederalHolidayCalendar bhour\_us = pd.offsets.CustomBusinessHour(calendar=USFederalHolidayCalendar()) # Friday b... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.005811320152133703,
0.01243494264781475,
0.03159686177968979,
0.002030428033322096,
-0.047371573746204376,
0.011620246805250645,
0.021564440801739693,
-0.06617908179759979,
-0.04946184903383255,
-0.03643970564007759,
0.01813305728137493,
-0.06261935830116272,
-0.07761778682470322,
-0.00... | -0.003639 |
offsets: .. ipython:: python pd.date\_range(start, periods=10, freq="2h20min") pd.date\_range(start, periods=10, freq="1D10us") Anchored offsets ~~~~~~~~~~~~~~~~ For some frequencies you can specify an anchoring suffix: .. csv-table:: :header: "Alias", "Description" :widths: 15, 100 "W\-SUN", "weekly frequency, week en... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.011976384557783604,
0.022339127957820892,
-0.0285806804895401,
0.0389094352722168,
-0.04382474347949028,
0.03329930827021599,
-0.06139814853668213,
-0.020903808996081352,
-0.055199816823005676,
-0.022590043023228645,
0.013567954301834106,
-0.07892705500125885,
-0.022196471691131592,
-0.... | -0.026168 |
occur on fixed dates (e.g., US Memorial Day or July 4th) an observance rule determines when that holiday is observed if it falls on a weekend or some other non-observed day. Defined observance rules are: .. csv-table:: :header: "Rule", "Description" :widths: 15, 70 "next\_workday", "move Saturday and Sunday to Monday" ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
0.018914654850959778,
0.026576898992061615,
0.030612606555223465,
-0.002042205538600683,
0.05280740186572075,
0.007071401923894882,
-0.0470399335026741,
-0.08335322886705399,
-0.04113762080669403,
0.06546799838542938,
-0.005238956306129694,
-0.06600161641836166,
0.00626364117488265,
0.0394... | -0.004773 |
= pd.date\_range("1/1/2010", periods=3, freq=3 \* pd.offsets.BDay()) ts = pd.Series(np.random.randn(3), index=dr) ts ts.asfreq(pd.offsets.BDay()) ``asfreq`` provides a further convenience so you can specify an interpolation method for any gaps that may appear after the frequency conversion. .. ipython:: python ts.asfre... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.09300675988197327,
-0.010639029555022717,
-0.027158040553331375,
0.07859426736831665,
-0.04385852813720703,
-0.05601666867733002,
-0.05338572338223457,
0.006128628738224506,
-0.046922776848077774,
-0.028142906725406647,
-0.02414359524846077,
-0.07977081090211868,
-0.054192934185266495,
... | 0.021073 |
When you don't want to use a method to fill these values, e.g. ``fill\_method`` is ``None``, then intermediate values will be filled with ``NaN``. Since ``resample`` is a time-based groupby, the following is a method to efficiently resample only the groups that are not all ``NaN``. .. ipython:: python rng = pd.date\_ra... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.0893293246626854,
-0.032302651554346085,
0.07054401189088821,
-0.012497443705797195,
-0.030113497748970985,
-0.04612995311617851,
0.010114206932485104,
0.014254795387387276,
0.013632834888994694,
0.024800928309559822,
-0.02781001664698124,
-0.06014712527394295,
-0.057197101414203644,
-0... | 0.053535 |
create inconsistencies with some frequencies that do not meet this criteria. To change this behavior you can specify a fixed Timestamp with the argument ``origin``. For example: .. ipython:: python start, end = "2000-10-01 23:30:00", "2000-10-02 00:30:00" middle = "2000-10-02 00:00:00" rng = pd.date\_range(start, end, ... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.08424878865480423,
-0.010763999074697495,
0.07816926389932632,
0.01721283234655857,
-0.008527040481567383,
-0.06360629945993423,
-0.026493048295378685,
-0.007959906943142414,
0.03293778747320175,
-0.019580282270908356,
-0.05284107103943825,
-0.03679333254694939,
-0.10443053394556046,
0.... | -0.019313 |
:okexcept: p + pd.offsets.Minute(5) If ``Period`` has other frequencies, only the same ``offsets`` can be added. Otherwise, ``ValueError`` will be raised. .. ipython:: python p = pd.Period("2014-07", freq="M") p + pd.offsets.MonthEnd(3) .. ipython:: python :okexcept: p + pd.offsets.MonthBegin(3) Taking the difference o... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.04613591358065605,
0.023418525233864784,
0.002240613102912903,
0.001008541090413928,
-0.007233587093651295,
0.0402943417429924,
-0.019654780626296997,
0.00014531560009345412,
0.01654854230582714,
-0.05706924945116043,
0.02925298735499382,
-0.06375132501125336,
-0.026627011597156525,
-0.... | 0.045592 |
the super-period that includes the input period: .. ipython:: python p = pd.Period("2011-12", freq="M") p.asfreq("Y-NOV") Note that since we converted to an annual frequency that ends the year in November, the monthly period of December 2011 is actually in the 2012 Y-NOV period. .. \_timeseries.quarterly: Period conver... | https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/timeseries.rst | main | pandas | [
-0.02456633560359478,
-0.020901774987578392,
-0.050804220139980316,
0.0018044846365228295,
-0.015539824962615967,
-0.005012264475226402,
-0.11403047293424606,
-0.035487573593854904,
-0.004841220565140247,
-0.02709781564772129,
0.05597217008471489,
-0.0061690835282206535,
-0.0670139417052269,... | 0.001487 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.