Skip to content

Commit

Permalink
Merge branch 'main' into ref-errorbars
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Nov 9, 2023
2 parents ab34c96 + d734496 commit 46a98db
Show file tree
Hide file tree
Showing 74 changed files with 559 additions and 465 deletions.
2 changes: 0 additions & 2 deletions doc/source/user_guide/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,12 @@ Parquet
Writing to a Parquet file:

.. ipython:: python
:okwarning:
df.to_parquet("foo.parquet")
Reading from a Parquet file Store using :func:`read_parquet`:

.. ipython:: python
:okwarning:
pd.read_parquet("foo.parquet")
Expand Down
11 changes: 0 additions & 11 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,6 @@ For line-delimited json files, pandas can also return an iterator which reads in
Line-limited json can also be read using the pyarrow reader by specifying ``engine="pyarrow"``.

.. ipython:: python
:okwarning:
from io import BytesIO
df = pd.read_json(BytesIO(jsonl.encode()), lines=True, engine="pyarrow")
Expand Down Expand Up @@ -5372,15 +5371,13 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
Write to a parquet file.

.. ipython:: python
:okwarning:
df.to_parquet("example_pa.parquet", engine="pyarrow")
df.to_parquet("example_fp.parquet", engine="fastparquet")
Read from a parquet file.

.. ipython:: python
:okwarning:
result = pd.read_parquet("example_fp.parquet", engine="fastparquet")
result = pd.read_parquet("example_pa.parquet", engine="pyarrow")
Expand All @@ -5390,7 +5387,6 @@ Read from a parquet file.
By setting the ``dtype_backend`` argument you can control the default dtypes used for the resulting DataFrame.

.. ipython:: python
:okwarning:
result = pd.read_parquet("example_pa.parquet", engine="pyarrow", dtype_backend="pyarrow")
Expand All @@ -5404,7 +5400,6 @@ By setting the ``dtype_backend`` argument you can control the default dtypes use
Read only certain columns of a parquet file.

.. ipython:: python
:okwarning:
result = pd.read_parquet(
"example_fp.parquet",
Expand Down Expand Up @@ -5433,7 +5428,6 @@ Serializing a ``DataFrame`` to parquet may include the implicit index as one or
more columns in the output file. Thus, this code:

.. ipython:: python
:okwarning:
df = pd.DataFrame({"a": [1, 2], "b": [3, 4]})
df.to_parquet("test.parquet", engine="pyarrow")
Expand All @@ -5450,7 +5444,6 @@ If you want to omit a dataframe's indexes when writing, pass ``index=False`` to
:func:`~pandas.DataFrame.to_parquet`:

.. ipython:: python
:okwarning:
df.to_parquet("test.parquet", index=False)
Expand All @@ -5473,7 +5466,6 @@ Partitioning Parquet files
Parquet supports partitioning of data based on the values of one or more columns.

.. ipython:: python
:okwarning:
df = pd.DataFrame({"a": [0, 0, 1, 1], "b": [0, 1, 0, 1]})
df.to_parquet(path="test", engine="pyarrow", partition_cols=["a"], compression=None)
Expand Down Expand Up @@ -5539,14 +5531,12 @@ ORC format, :func:`~pandas.read_orc` and :func:`~pandas.DataFrame.to_orc`. This
Write to an orc file.

.. ipython:: python
:okwarning:
df.to_orc("example_pa.orc", engine="pyarrow")
Read from an orc file.

.. ipython:: python
:okwarning:
result = pd.read_orc("example_pa.orc")
Expand All @@ -5555,7 +5545,6 @@ Read from an orc file.
Read only certain columns of an orc file.

.. ipython:: python
:okwarning:
result = pd.read_orc(
"example_pa.orc",
Expand Down
3 changes: 0 additions & 3 deletions doc/source/user_guide/pyarrow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ To convert a :external+pyarrow:py:class:`pyarrow.Table` to a :class:`DataFrame`,
:external+pyarrow:py:meth:`pyarrow.Table.to_pandas` method with ``types_mapper=pd.ArrowDtype``.

.. ipython:: python
:okwarning:
table = pa.table([pa.array([1, 2, 3], type=pa.int64())], names=["a"])
Expand Down Expand Up @@ -165,7 +164,6 @@ functions provide an ``engine`` keyword that can dispatch to PyArrow to accelera
* :func:`read_feather`

.. ipython:: python
:okwarning:
import io
data = io.StringIO("""a,b,c
Expand All @@ -180,7 +178,6 @@ PyArrow-backed data by specifying the parameter ``dtype_backend="pyarrow"``. A r
``engine="pyarrow"`` to necessarily return PyArrow-backed data.

.. ipython:: python
:okwarning:
import io
data = io.StringIO("""a,b,c,d,e,f,g,h,i
Expand Down
3 changes: 0 additions & 3 deletions doc/source/user_guide/scale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ To load the columns we want, we have two options.
Option 1 loads in all the data and then filters to what we need.

.. ipython:: python
:okwarning:
columns = ["id_0", "name_0", "x_0", "y_0"]
Expand All @@ -60,7 +59,6 @@ Option 1 loads in all the data and then filters to what we need.
Option 2 only loads the columns we request.

.. ipython:: python
:okwarning:
pd.read_parquet("timeseries_wide.parquet", columns=columns)
Expand Down Expand Up @@ -202,7 +200,6 @@ counts up to this point. As long as each individual file fits in memory, this wi
work for arbitrary-sized datasets.

.. ipython:: python
:okwarning:
%%time
files = pathlib.Path("data/timeseries/").glob("ts*.parquet")
Expand Down
30 changes: 15 additions & 15 deletions doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ into ``freq`` keyword arguments. The available date offsets and associated frequ
:class:`~pandas.tseries.offsets.BQuarterEnd`, ``'BQ``, "business quarter end"
:class:`~pandas.tseries.offsets.BQuarterBegin`, ``'BQS'``, "business quarter begin"
:class:`~pandas.tseries.offsets.FY5253Quarter`, ``'REQ'``, "retail (aka 52-53 week) quarter"
:class:`~pandas.tseries.offsets.YearEnd`, ``'Y'``, "calendar year end"
:class:`~pandas.tseries.offsets.YearEnd`, ``'YE'``, "calendar year end"
:class:`~pandas.tseries.offsets.YearBegin`, ``'YS'`` or ``'BYS'``,"calendar year begin"
:class:`~pandas.tseries.offsets.BYearEnd`, ``'BY'``, "business year end"
:class:`~pandas.tseries.offsets.BYearBegin`, ``'BYS'``, "business year begin"
Expand Down Expand Up @@ -1252,7 +1252,7 @@ frequencies. We will refer to these aliases as *offset aliases*.
"BQ", "business quarter end frequency"
"QS", "quarter start frequency"
"BQS", "business quarter start frequency"
"Y", "year end frequency"
"YE", "year end frequency"
"BY", "business year end frequency"
"YS", "year start frequency"
"BYS", "business year start frequency"
Expand Down Expand Up @@ -1379,18 +1379,18 @@ For some frequencies you can specify an anchoring suffix:
"(B)Q(E)(S)\-SEP", "quarterly frequency, year ends in September"
"(B)Q(E)(S)\-OCT", "quarterly frequency, year ends in October"
"(B)Q(E)(S)\-NOV", "quarterly frequency, year ends in November"
"(B)Y(S)\-DEC", "annual frequency, anchored end of December. Same as 'Y'"
"(B)Y(S)\-JAN", "annual frequency, anchored end of January"
"(B)Y(S)\-FEB", "annual frequency, anchored end of February"
"(B)Y(S)\-MAR", "annual frequency, anchored end of March"
"(B)Y(S)\-APR", "annual frequency, anchored end of April"
"(B)Y(S)\-MAY", "annual frequency, anchored end of May"
"(B)Y(S)\-JUN", "annual frequency, anchored end of June"
"(B)Y(S)\-JUL", "annual frequency, anchored end of July"
"(B)Y(S)\-AUG", "annual frequency, anchored end of August"
"(B)Y(S)\-SEP", "annual frequency, anchored end of September"
"(B)Y(S)\-OCT", "annual frequency, anchored end of October"
"(B)Y(S)\-NOV", "annual frequency, anchored end of November"
"(B)Y(E)(S)\-DEC", "annual frequency, anchored end of December. Same as 'YE'"
"(B)Y(E)(S)\-JAN", "annual frequency, anchored end of January"
"(B)Y(E)(S)\-FEB", "annual frequency, anchored end of February"
"(B)Y(E)(S)\-MAR", "annual frequency, anchored end of March"
"(B)Y(E)(S)\-APR", "annual frequency, anchored end of April"
"(B)Y(E)(S)\-MAY", "annual frequency, anchored end of May"
"(B)Y(E)(S)\-JUN", "annual frequency, anchored end of June"
"(B)Y(E)(S)\-JUL", "annual frequency, anchored end of July"
"(B)Y(E)(S)\-AUG", "annual frequency, anchored end of August"
"(B)Y(E)(S)\-SEP", "annual frequency, anchored end of September"
"(B)Y(E)(S)\-OCT", "annual frequency, anchored end of October"
"(B)Y(E)(S)\-NOV", "annual frequency, anchored end of November"

These can be used as arguments to ``date_range``, ``bdate_range``, constructors
for ``DatetimeIndex``, as well as various other timeseries-related functions
Expand Down Expand Up @@ -1686,7 +1686,7 @@ the end of the interval.
.. warning::

The default values for ``label`` and ``closed`` is '**left**' for all
frequency offsets except for 'ME', 'Y', 'QE', 'BME', 'BY', 'BQ', and 'W'
frequency offsets except for 'ME', 'YE', 'QE', 'BME', 'BY', 'BQ', and 'W'
which all have a default of 'right'.

This might unintendedly lead to looking ahead, where the value for a later
Expand Down
1 change: 0 additions & 1 deletion doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ When this keyword is set to ``"pyarrow"``, then these functions will return pyar
* :meth:`Series.convert_dtypes`

.. ipython:: python
:okwarning:
import io
data = io.StringIO("""a,b,c,d,e,f,g,h,i
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ including other versions of pandas.

Fixed regressions
~~~~~~~~~~~~~~~~~
-
- Fixed infinite recursion from operations that return a new object on some DataFrame subclasses (:issue:`55763`)
-

.. ---------------------------------------------------------------------------
Expand Down
27 changes: 6 additions & 21 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,14 @@ Other API changes
Deprecations
~~~~~~~~~~~~

Deprecate aliases ``M`` and ``Q`` in favour of ``ME`` and ``QE`` for offsets
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Deprecate aliases ``M``, ``Q``, and ``Y`` in favour of ``ME``, ``QE``, and ``YE`` for offsets
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The alias ``M`` is deprecated in favour of ``ME`` for offsets, please use ``ME`` for "month end" instead of ``M`` (:issue:`9586`)
Deprecated the following frequency aliases (:issue:`9586`):

For example:

*Previous behavior*:

.. code-block:: ipython
In [7]: pd.date_range('2020-01-01', periods=3, freq='M')
Out [7]:
DatetimeIndex(['2020-01-31', '2020-02-29', '2020-03-31'],
dtype='datetime64[ns]', freq='M')
*Future behavior*:

.. ipython:: python
pd.date_range('2020-01-01', periods=3, freq='ME')
The alias ``Q`` is deprecated in favour of ``QE`` for offsets, please use ``QE`` for "quarter end" instead of ``Q`` (:issue:`9586`)
- ``M`` (month end) has been renamed ``ME`` for offsets
- ``Q`` (quarter end) has been renamed ``QE`` for offsets
- ``Y`` (year end) has been renamed ``YE`` for offsets

For example:

Expand Down
39 changes: 39 additions & 0 deletions pandas/_libs/tslibs/dtypes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ OFFSET_TO_PERIOD_FREQSTR: dict = {
"QE-SEP": "Q-SEP",
"QE-OCT": "Q-OCT",
"QE-NOV": "Q-NOV",
"YE": "Y",
"YE-DEC": "Y-DEC",
"YE-JAN": "Y-JAN",
"YE-FEB": "Y-FEB",
"YE-MAR": "Y-MAR",
"YE-APR": "Y-APR",
"YE-MAY": "Y-MAY",
"YE-JUN": "Y-JUN",
"YE-JUL": "Y-JUL",
"YE-AUG": "Y-AUG",
"YE-SEP": "Y-SEP",
"YE-OCT": "Y-OCT",
"YE-NOV": "Y-NOV",
"W": "W",
"ME": "M",
"Y": "Y",
Expand All @@ -236,6 +249,32 @@ OFFSET_DEPR_FREQSTR: dict[str, str]= {
"Q-SEP": "QE-SEP",
"Q-OCT": "QE-OCT",
"Q-NOV": "QE-NOV",
"Y": "YE",
"Y-DEC": "YE-DEC",
"Y-JAN": "YE-JAN",
"Y-FEB": "YE-FEB",
"Y-MAR": "YE-MAR",
"Y-APR": "YE-APR",
"Y-MAY": "YE-MAY",
"Y-JUN": "YE-JUN",
"Y-JUL": "YE-JUL",
"Y-AUG": "YE-AUG",
"Y-SEP": "YE-SEP",
"Y-OCT": "YE-OCT",
"Y-NOV": "YE-NOV",
"A": "YE",
"A-DEC": "YE-DEC",
"A-JAN": "YE-JAN",
"A-FEB": "YE-FEB",
"A-MAR": "YE-MAR",
"A-APR": "YE-APR",
"A-MAY": "YE-MAY",
"A-JUN": "YE-JUN",
"A-JUL": "YE-JUL",
"A-AUG": "YE-AUG",
"A-SEP": "YE-SEP",
"A-OCT": "YE-OCT",
"A-NOV": "YE-NOV",
}
cdef dict c_OFFSET_TO_PERIOD_FREQSTR = OFFSET_TO_PERIOD_FREQSTR
cdef dict c_OFFSET_DEPR_FREQSTR = OFFSET_DEPR_FREQSTR
Expand Down
15 changes: 12 additions & 3 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ cdef class YearEnd(YearOffset):
"""

_default_month = 12
_prefix = "Y"
_prefix = "YE"
_day_opt = "end"

cdef readonly:
Expand Down Expand Up @@ -4562,7 +4562,7 @@ prefix_mapping = {
offset._prefix: offset
for offset in [
YearBegin, # 'YS'
YearEnd, # 'Y'
YearEnd, # 'YE'
BYearBegin, # 'BYS'
BYearEnd, # 'BY'
BusinessDay, # 'B'
Expand Down Expand Up @@ -4604,7 +4604,7 @@ _lite_rule_alias = {
"W": "W-SUN",
"QE": "QE-DEC",

"Y": "Y-DEC", # YearEnd(month=12),
"YE": "YE-DEC", # YearEnd(month=12),
"YS": "YS-JAN", # YearBegin(month=1),
"BY": "BY-DEC", # BYearEnd(month=12),
"BYS": "BYS-JAN", # BYearBegin(month=1),
Expand Down Expand Up @@ -4637,6 +4637,7 @@ _dont_uppercase = {
"qe-sep",
"qe-oct",
"qe-nov",
"ye",
}


Expand Down Expand Up @@ -4762,6 +4763,14 @@ cpdef to_offset(freq, bint is_period=False):
f"instead of \'{name}\'"
)
elif is_period is True and name in c_OFFSET_DEPR_FREQSTR:
if name.startswith("A"):
warnings.warn(
f"\'{name}\' is deprecated and will be removed in a future "
f"version, please use \'{c_DEPR_ABBREVS.get(name)}\' "
f"instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
name = c_OFFSET_DEPR_FREQSTR.get(name)

if sep != "" and not sep.isspace():
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ def isocalendar(self) -> DataFrame:
Examples
--------
>>> datetime_series = pd.Series(
... pd.date_range("2000-01-01", periods=3, freq="Y")
... pd.date_range("2000-01-01", periods=3, freq="YE")
... )
>>> datetime_series
0 2000-12-31
Expand Down Expand Up @@ -2058,10 +2058,10 @@ def isocalendar(self) -> DataFrame:
This method is available on Series with datetime values under
the ``.dt`` accessor, and directly on DatetimeIndex.

>>> idx = pd.date_range("2012-01-01", "2015-01-01", freq="Y")
>>> idx = pd.date_range("2012-01-01", "2015-01-01", freq="YE")
>>> idx
DatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'],
dtype='datetime64[ns]', freq='Y-DEC')
dtype='datetime64[ns]', freq='YE-DEC')
>>> idx.is_leap_year
array([ True, False, False])

Expand Down
Loading

0 comments on commit 46a98db

Please sign in to comment.