Skip to content

TST: Series repr with pyarrow date32 type #48258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
63091ac
BUG: is_datetime64tz_dtype shortcut only for DatetimeTZDtype
mroeschke Aug 25, 2022
99bfd65
add another whatsnew note
mroeschke Aug 25, 2022
17d87cd
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 25, 2022
46dde84
Use frame_or_series
mroeschke Aug 25, 2022
eff21a0
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 26, 2022
aa3b419
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 26, 2022
da96b81
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 29, 2022
5d78da7
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 29, 2022
4dfb27c
more specific warning condition
mroeschke Aug 29, 2022
9a58c96
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 29, 2022
21f1e52
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Aug 31, 2022
bfd28b8
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 1, 2022
13f5f3a
Try something random
mroeschke Sep 2, 2022
cce9a12
Remove random try
mroeschke Sep 2, 2022
8fe8de2
try skipping arg* tests for pyarrow?
mroeschke Sep 2, 2022
7607ef8
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 2, 2022
55b3c9d
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 6, 2022
f1253db
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 7, 2022
7c14b52
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 7, 2022
2f55e02
Add test for needs_i8_conversion
mroeschke Sep 7, 2022
59cc92c
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 9, 2022
0ad06c3
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 9, 2022
e83c007
Force colors for failures?
mroeschke Sep 9, 2022
011201d
PY_COLOR?
mroeschke Sep 9, 2022
6b02ed4
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 9, 2022
911c46e
See if no color logs errors
mroeschke Sep 10, 2022
59ea2a2
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 13, 2022
88d2e2c
Undo skips
mroeschke Sep 13, 2022
ddf8f61
Missed skip
mroeschke Sep 13, 2022
d548138
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 13, 2022
17b78e9
Remove test
mroeschke Sep 13, 2022
e051144
Undo test removal
mroeschke Sep 13, 2022
21d152c
Try not testing pyarrow timedelta types
mroeschke Sep 13, 2022
161ad6d
Revert the is_datetime64tz_dtype change
mroeschke Sep 14, 2022
91d4627
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 14, 2022
21ff5fd
Merge remote-tracking branch 'upstream/main' into bug/is_dttz_dtype
mroeschke Sep 14, 2022
8ef9f46
Validate it's pa.duration again
mroeschke Sep 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ PyArrow

This feature is experimental, and the API can change in a future release without warning.

The ``dtype`` argument of :class:`Series` and :class:`DataFrame` can accept a string of a `pyarrow data type <https://arrow.apache.org/docs/python/api/datatypes.html>`__
with ``pyarrow`` in brackets e.g. ``"int64[pyarrow]"`` or, for pyarrow data types that take parameters, a :class:`ArrowDtype`
initialized with a ``pyarrow.DataType``.

The :class:`arrays.ArrowExtensionArray` is backed by a :external+pyarrow:py:class:`pyarrow.ChunkedArray` with a
:external+pyarrow:py:class:`pyarrow.DataType` instead of a NumPy array and data type. The ``.dtype`` of a :class:`arrays.ArrowExtensionArray`
is an :class:`ArrowDtype`.
Expand Down
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ initialized with a ``pyarrow.DataType``.
Most operations are supported and have been implemented using `pyarrow compute <https://arrow.apache.org/docs/python/api/compute.html>`__ functions.
We recommend installing the latest version of PyArrow to access the most recently implemented compute functions.

Please view the :ref:`API reference <api.arrays.arrow>` for more information.

.. warning::

This feature is experimental, and the API can change in a future release without warning.
Expand Down Expand Up @@ -1034,7 +1036,6 @@ Conversion
- Bug in :meth:`DataFrame.apply` that returns a :class:`DataFrame` instead of a :class:`Series` when applied to an empty :class:`DataFrame` and ``axis=1`` (:issue:`39111`)
- Bug when inferring the dtype from an iterable that is *not* a NumPy ``ndarray`` consisting of all NumPy unsigned integer scalars did not result in an unsigned integer dtype (:issue:`47294`)
- Bug in :meth:`DataFrame.eval` when pandas objects (e.g. ``'Timestamp'``) were column names (:issue:`44603`)
-

Strings
^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions pandas/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
for unit in ["s", "ms", "us", "ns"]
for tz in [None, "UTC", "US/Pacific", "US/Eastern"]
]
TIMEDELTA_PYARROW_DTYPES = [pa.duration(unit) for unit in ["s", "ms", "us", "ns"]]
# TIMEDELTA_PYARROW_DTYPES = [pa.duration(unit) for unit in ["s", "ms", "us", "ns"]]

BOOL_PYARROW_DTYPES = [pa.bool_()]

Expand All @@ -227,7 +227,7 @@
+ TIME_PYARROW_DTYPES
+ DATE_PYARROW_DTYPES
+ DATETIME_PYARROW_DTYPES
+ TIMEDELTA_PYARROW_DTYPES
# + TIMEDELTA_PYARROW_DTYPES
+ BOOL_PYARROW_DTYPES
)

Expand Down
7 changes: 7 additions & 0 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ class ArrowExtensionArray(OpsMixin, ExtensionArray):
<ArrowExtensionArray>
[1, 1, <NA>]
Length: 3, dtype: int64[pyarrow]

Create a ArrowExtensionArray directly from an pyarrow array.
>>> import pyarrow as pa
>>> pd.arrays.ArrowExtensionArray(pa.array([1, 1, None]))
<ArrowExtensionArray>
[1, 1, <NA>]
Length: 3, dtype: int64[pyarrow]
""" # noqa: E501 (http link too long)

_data: pa.ChunkedArray
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,3 +1750,10 @@ def test_mode(data_for_grouping, dropna, take_idx, exp_idx, request):
result = ser.mode(dropna=dropna)
expected = pd.Series(data_for_grouping.take(exp_idx))
tm.assert_series_equal(result, expected)


def test_repr_from_arrow_array(data, frame_or_series):
# GH 48238
pa_array = pa.array([data[0], None])
result = frame_or_series(pa_array, dtype=ArrowDtype(pa_array.type))
repr(result)