Skip to content

Commit bcc770b

Browse files
committed
MERGE: resolve master merge conflicts by accepting master
2 parents 6f78520 + 37dfcc1 commit bcc770b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+598
-450
lines changed

doc/source/user_guide/io.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4683,6 +4683,7 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
46834683
Write to a parquet file.
46844684

46854685
.. ipython:: python
4686+
:okwarning:
46864687
46874688
df.to_parquet('example_pa.parquet', engine='pyarrow')
46884689
df.to_parquet('example_fp.parquet', engine='fastparquet')

doc/source/whatsnew/v1.0.0.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ Other enhancements
204204
- Roundtripping DataFrames with nullable integer or string data types to parquet
205205
(:meth:`~DataFrame.to_parquet` / :func:`read_parquet`) using the `'pyarrow'` engine
206206
now preserve those data types with pyarrow >= 1.0.0 (:issue:`20612`).
207+
- The ``partition_cols`` argument in :meth:`DataFrame.to_parquet` now accepts a string (:issue:`27117`)
207208

208209
Build Changes
209210
^^^^^^^^^^^^^
@@ -432,6 +433,8 @@ Optional libraries below the lowest tested version may still work, but are not c
432433
+-----------------+-----------------+---------+
433434
| pytables | 3.4.2 | |
434435
+-----------------+-----------------+---------+
436+
| s3fs | 0.3.0 | X |
437+
+-----------------+-----------------+---------+
435438
| scipy | 0.19.0 | |
436439
+-----------------+-----------------+---------+
437440
| sqlalchemy | 1.1.4 | |
@@ -453,7 +456,7 @@ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for mor
453456
Other API changes
454457
^^^^^^^^^^^^^^^^^
455458

456-
- Bumpded the minimum supported version of ``s3fs`` from 0.0.8 to 0.3.0 (:issue:`28616`)
459+
- Bumped the minimum supported version of ``s3fs`` from 0.0.8 to 0.3.0 (:issue:`28616`)
457460
- :class:`pandas.core.groupby.GroupBy.transform` now raises on invalid operation names (:issue:`27489`)
458461
- :meth:`pandas.api.types.infer_dtype` will now return "integer-na" for integer and ``np.nan`` mix (:issue:`27283`)
459462
- :meth:`MultiIndex.from_arrays` will no longer infer names from arrays if ``names=None`` is explicitly provided (:issue:`27292`)
@@ -491,6 +494,7 @@ Deprecations
491494
- :meth:`Categorical.take_nd` is deprecated, use :meth:`Categorical.take` instead (:issue:`27745`)
492495
- The parameter ``numeric_only`` of :meth:`Categorical.min` and :meth:`Categorical.max` is deprecated and replaced with ``skipna`` (:issue:`25303`)
493496
- The parameter ``label`` in :func:`lreshape` has been deprecated and will be removed in a future version (:issue:`29742`)
497+
- ``pandas.core.index`` has been deprecated and will be removed in a future version, the public classes are available in the top-level namespace (:issue:`19711`)
494498
-
495499

496500
.. _whatsnew_1000.prior_deprecations:
@@ -697,6 +701,7 @@ Datetimelike
697701
- Bug in :meth:`DatetimeIndex.strftime` and :meth:`Series.dt.strftime` where ``NaT`` was converted to the string ``'NaT'`` instead of ``np.nan`` (:issue:`29578`)
698702
- Bug in :attr:`Timestamp.resolution` being a property instead of a class attribute (:issue:`29910`)
699703
- Bug in :func:`pandas.to_datetime` when called with ``None`` raising ``TypeError`` instead of returning ``NaT`` (:issue:`30011`)
704+
- Bug in :func:`pandas.to_datetime` failing for `deques` when using ``cache=True`` (the default) (:issue:`29403`)
700705
- Bug in :func:`pandas.to_datetime` when called with ``Series`` storing ``IntegerArray`` raising ``TypeError`` instead of returning ``Series`` (:issue:`30050`)
701706

702707
Timedelta
@@ -872,7 +877,8 @@ Other
872877
- Bug in :meth:`DataFrame.append` that raised ``IndexError`` when appending with empty list (:issue:`28769`)
873878
- Fix :class:`AbstractHolidayCalendar` to return correct results for
874879
years after 2030 (now goes up to 2200) (:issue:`27790`)
875-
- Fixed :class:`IntegerArray` returning ``NA`` rather than ``inf`` for operations dividing by 0 (:issue:`27398`)
880+
- Fixed :class:`IntegerArray` returning ``inf`` rather than ``NaN`` for operations dividing by 0 (:issue:`27398`)
881+
- Fixed ``pow`` operations for :class:`IntegerArray` when the other value is ``0`` or ``1`` (:issue:`29997`)
876882
- Bug in :meth:`Series.count` raises if use_inf_as_na is enabled (:issue:`29478`)
877883

878884

pandas/_libs/internals.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ cdef class BlockPlacement:
9696
return self._as_array
9797

9898
def isin(self, arr):
99-
from pandas.core.index import Int64Index
99+
from pandas.core.indexes.api import Int64Index
100100
return Int64Index(self.as_array, copy=False).isin(arr)
101101

102102
@property

pandas/_libs/lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def astype_str(arr: ndarray, skipna: bool=False) -> ndarray[object]:
598598
@cython.boundscheck(False)
599599
def clean_index_list(obj: list):
600600
"""
601-
Utility used in ``pandas.core.index.ensure_index``.
601+
Utility used in ``pandas.core.indexes.api.ensure_index``.
602602
"""
603603
cdef:
604604
Py_ssize_t i, n = len(obj)

pandas/_libs/skiplist.pxd

Lines changed: 0 additions & 24 deletions
This file was deleted.

pandas/_libs/window/aggregations.pyx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,27 @@ from pandas._libs.algos import is_monotonic
2222

2323
from pandas._libs.util cimport numeric
2424

25-
from pandas._libs.skiplist cimport (
26-
skiplist_t, skiplist_init, skiplist_destroy, skiplist_get, skiplist_insert,
27-
skiplist_remove)
25+
cdef extern from "../src/skiplist.h":
26+
ctypedef struct node_t:
27+
node_t **next
28+
int *width
29+
double value
30+
int is_nil
31+
int levels
32+
int ref_count
33+
34+
ctypedef struct skiplist_t:
35+
node_t *head
36+
node_t **tmp_chain
37+
int *tmp_steps
38+
int size
39+
int maxlevels
40+
41+
skiplist_t* skiplist_init(int) nogil
42+
void skiplist_destroy(skiplist_t*) nogil
43+
double skiplist_get(skiplist_t*, int, int*) nogil
44+
int skiplist_insert(skiplist_t*, double) nogil
45+
int skiplist_remove(skiplist_t*, double) nogil
2846

2947
cdef:
3048
float32_t MINfloat32 = np.NINF

pandas/core/api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import numpy as np
44

5+
from pandas._libs import NaT, Period, Timedelta, Timestamp
6+
from pandas._libs.missing import NA
7+
58
from pandas.core.dtypes.dtypes import (
69
CategoricalDtype,
710
DatetimeTZDtype,
@@ -26,24 +29,23 @@
2629
from pandas.core.arrays.string_ import StringDtype
2730
from pandas.core.construction import array
2831
from pandas.core.groupby import Grouper, NamedAgg
29-
from pandas.core.index import (
32+
from pandas.core.indexes.api import (
3033
CategoricalIndex,
3134
DatetimeIndex,
3235
Float64Index,
3336
Index,
3437
Int64Index,
3538
IntervalIndex,
3639
MultiIndex,
37-
NaT,
3840
PeriodIndex,
3941
RangeIndex,
4042
TimedeltaIndex,
4143
UInt64Index,
4244
)
43-
from pandas.core.indexes.datetimes import Timestamp, bdate_range, date_range
45+
from pandas.core.indexes.datetimes import bdate_range, date_range
4446
from pandas.core.indexes.interval import Interval, interval_range
45-
from pandas.core.indexes.period import Period, period_range
46-
from pandas.core.indexes.timedeltas import Timedelta, timedelta_range
47+
from pandas.core.indexes.period import period_range
48+
from pandas.core.indexes.timedeltas import timedelta_range
4749
from pandas.core.indexing import IndexSlice
4850
from pandas.core.series import Series
4951
from pandas.core.tools.datetimes import to_datetime
@@ -55,5 +57,3 @@
5557

5658
# DataFrame needs to be imported after NamedAgg to avoid a circular import
5759
from pandas.core.frame import DataFrame # isort:skip
58-
59-
from pandas._libs.missing import NA

pandas/core/apply.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def apply_series_generator(self) -> Tuple[ResType, "Index"]:
320320
series_gen = self.series_generator
321321
res_index = self.result_index
322322

323-
i = None
324323
keys = []
325324
results = {}
326325
if self.ignore_failures:

pandas/core/arrays/_ranges.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def _generate_range_overflow_safe_signed(
179179
# watch out for very special case in which we just slightly
180180
# exceed implementation bounds, but when passing the result to
181181
# np.arange will get a result slightly within the bounds
182-
assert endpoint >= 0
183182
result = np.uint64(endpoint) + np.uint64(addend)
184183
i64max = np.uint64(np.iinfo(np.int64).max)
185184
assert result > i64max

pandas/core/arrays/datetimes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,6 @@ def _validate_dt64_dtype(dtype):
21092109
dtype = pandas_dtype(dtype)
21102110
if is_dtype_equal(dtype, np.dtype("M8")):
21112111
# no precision, disallowed GH#24806
2112-
dtype = _NS_DTYPE
21132112
msg = (
21142113
"Passing in 'datetime64' dtype with no precision is not allowed. "
21152114
"Please pass in 'datetime64[ns]' instead."

pandas/core/arrays/integer.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def itemsize(self):
7878

7979
@classmethod
8080
def construct_array_type(cls):
81-
"""Return the array type associated with this dtype
81+
"""
82+
Return the array type associated with this dtype.
8283
8384
Returns
8485
-------
@@ -718,13 +719,13 @@ def _create_arithmetic_method(cls, op):
718719
@unpack_zerodim_and_defer(op.__name__)
719720
def integer_arithmetic_method(self, other):
720721

721-
mask = None
722+
omask = None
722723

723724
if getattr(other, "ndim", 0) > 1:
724725
raise NotImplementedError("can only perform ops with 1-d structures")
725726

726727
if isinstance(other, IntegerArray):
727-
other, mask = other._data, other._mask
728+
other, omask = other._data, other._mask
728729

729730
elif is_list_like(other):
730731
other = np.asarray(other)
@@ -742,17 +743,28 @@ def integer_arithmetic_method(self, other):
742743
raise TypeError("can only perform ops with numeric values")
743744

744745
# nans propagate
745-
if mask is None:
746+
if omask is None:
746747
mask = self._mask.copy()
747748
else:
748-
mask = self._mask | mask
749+
mask = self._mask | omask
749750

750-
# 1 ** np.nan is 1. So we have to unmask those.
751751
if op_name == "pow":
752-
mask = np.where(self == 1, False, mask)
752+
# 1 ** x is 1.
753+
mask = np.where((self._data == 1) & ~self._mask, False, mask)
754+
# x ** 0 is 1.
755+
if omask is not None:
756+
mask = np.where((other == 0) & ~omask, False, mask)
757+
else:
758+
mask = np.where(other == 0, False, mask)
753759

754760
elif op_name == "rpow":
755-
mask = np.where(other == 1, False, mask)
761+
# 1 ** x is 1.
762+
if omask is not None:
763+
mask = np.where((other == 1) & ~omask, False, mask)
764+
else:
765+
mask = np.where(other == 1, False, mask)
766+
# x ** 0 is 1.
767+
mask = np.where((self._data == 0) & ~self._mask, False, mask)
756768

757769
with np.errstate(all="ignore"):
758770
result = op(self._data, other)

pandas/core/arrays/numpy_.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ def construct_from_string(cls, string):
7979
f"Cannot construct a 'PandasDtype' from '{string}'"
8080
) from err
8181

82+
@classmethod
8283
def construct_array_type(cls):
84+
"""
85+
Return the array type associated with this dtype.
86+
87+
Returns
88+
-------
89+
type
90+
"""
8391
return PandasArray
8492

8593
@property

pandas/core/arrays/sparse/dtype.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ def __repr__(self) -> str:
168168

169169
@classmethod
170170
def construct_array_type(cls):
171+
"""
172+
Return the array type associated with this dtype.
173+
174+
Returns
175+
-------
176+
type
177+
"""
171178
from .array import SparseArray
172179

173180
return SparseArray

pandas/core/arrays/sparse/scipy_sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
from collections import OrderedDict
77

8-
from pandas.core.index import Index, MultiIndex
8+
from pandas.core.indexes.api import Index, MultiIndex
99
from pandas.core.series import Series
1010

1111

pandas/core/arrays/timedeltas.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,6 @@ def _validate_td64_dtype(dtype):
11221122
dtype = pandas_dtype(dtype)
11231123
if is_dtype_equal(dtype, np.dtype("timedelta64")):
11241124
# no precision disallowed GH#24806
1125-
dtype = _TD_DTYPE
11261125
msg = (
11271126
"Passing in 'timedelta' dtype with no precision is not allowed. "
11281127
"Please pass in 'timedelta64[ns]' instead."

pandas/core/base.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def _aggregate(self, arg, *args, **kwargs):
309309
None if not required
310310
"""
311311
is_aggregator = lambda x: isinstance(x, (list, tuple, dict))
312-
is_nested_renamer = False
313312

314313
_axis = kwargs.pop("_axis", None)
315314
if _axis is None:
@@ -398,24 +397,7 @@ def _agg(arg, func):
398397
keys = list(arg.keys())
399398
result = OrderedDict()
400399

401-
# nested renamer
402-
if is_nested_renamer:
403-
result = list(_agg(arg, _agg_1dim).values())
404-
405-
if all(isinstance(r, dict) for r in result):
406-
407-
result, results = OrderedDict(), result
408-
for r in results:
409-
result.update(r)
410-
keys = list(result.keys())
411-
412-
else:
413-
414-
if self._selection is not None:
415-
keys = None
416-
417-
# some selection on the object
418-
elif self._selection is not None:
400+
if self._selection is not None:
419401

420402
sl = set(self._selection_list)
421403

pandas/core/construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
if TYPE_CHECKING:
5151
from pandas.core.series import Series # noqa: F401
52-
from pandas.core.index import Index # noqa: F401
52+
from pandas.core.indexes.api import Index # noqa: F401
5353

5454

5555
def array(

pandas/core/dtypes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def names(self) -> Optional[List[str]]:
183183
@classmethod
184184
def construct_array_type(cls):
185185
"""
186-
Return the array type associated with this dtype
186+
Return the array type associated with this dtype.
187187
188188
Returns
189189
-------

0 commit comments

Comments
 (0)