Skip to content

Commit e88a9cb

Browse files
authored
Merge branch 'main' into bugfix/57539-fix-to-sql
2 parents 25bd776 + 192db0d commit e88a9cb

File tree

22 files changed

+55
-94
lines changed

22 files changed

+55
-94
lines changed

doc/source/whatsnew/v2.2.2.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Fixed regressions
1515
~~~~~~~~~~~~~~~~~
1616
- :meth:`DataFrame.__dataframe__` was producing incorrect data buffers when the a column's type was a pandas nullable on with missing values (:issue:`56702`)
1717
- :meth:`DataFrame.__dataframe__` was producing incorrect data buffers when the a column's type was a pyarrow nullable on with missing values (:issue:`57664`)
18-
-
18+
- Fixed regression in precision of :func:`to_datetime` with string and ``unit`` input (:issue:`57051`)
1919

2020
.. ---------------------------------------------------------------------------
2121
.. _whatsnew_222.bug_fixes:
2222

2323
Bug fixes
2424
~~~~~~~~~
25+
- :meth:`DataFrame.__dataframe__` was producing incorrect data buffers when the column's type was nullable boolean (:issue:`55332`)
2526
- :meth:`DataFrame.__dataframe__` was showing bytemask instead of bitmask for ``'string[pyarrow]'`` validity buffer (:issue:`57762`)
2627
- :meth:`DataFrame.__dataframe__` was showing non-null validity buffer (instead of ``None``) ``'string[pyarrow]'`` without missing values (:issue:`57761`)
2728
- :meth:`DataFrame.to_sql` was failing to find the right table when using the schema argument (:issue:`57539`)

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Removal of prior version deprecations/changes
206206
- :meth:`SeriesGroupBy.agg` no longer pins the name of the group to the input passed to the provided ``func`` (:issue:`51703`)
207207
- All arguments except ``name`` in :meth:`Index.rename` are now keyword only (:issue:`56493`)
208208
- All arguments except the first ``path``-like argument in IO writers are now keyword only (:issue:`54229`)
209+
- Removed "freq" keyword from :class:`PeriodArray` constructor, use "dtype" instead (:issue:`52462`)
209210
- Removed the "closed" and "normalize" keywords in :meth:`DatetimeIndex.__new__` (:issue:`52628`)
210211
- Removed the "closed" and "unit" keywords in :meth:`TimedeltaIndex.__new__` (:issue:`52628`, :issue:`55499`)
211212
- All arguments in :meth:`Index.sort_values` are now keyword only (:issue:`56493`)

pandas/_libs/tslib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def array_with_unit_to_datetime(
275275
bint is_raise = errors == "raise"
276276
ndarray[int64_t] iresult
277277
tzinfo tz = None
278-
float fval
278+
double fval
279279

280280
assert is_coerce or is_raise
281281

pandas/core/arrays/period.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
cache_readonly,
5555
doc,
5656
)
57-
from pandas.util._exceptions import find_stack_level
5857

5958
from pandas.core.dtypes.common import (
6059
ensure_object,
@@ -135,11 +134,6 @@ class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
135134
dtype : PeriodDtype, optional
136135
A PeriodDtype instance from which to extract a `freq`. If both
137136
`freq` and `dtype` are specified, then the frequencies must match.
138-
freq : str or DateOffset
139-
The `freq` to use for the array. Mostly applicable when `values`
140-
is an ndarray of integers, when `freq` is required. When `values`
141-
is a PeriodArray (or box around), it's checked that ``values.freq``
142-
matches `freq`.
143137
copy : bool, default False
144138
Whether to copy the ordinals before storing.
145139
@@ -224,20 +218,7 @@ def _scalar_type(self) -> type[Period]:
224218
# --------------------------------------------------------------------
225219
# Constructors
226220

227-
def __init__(
228-
self, values, dtype: Dtype | None = None, freq=None, copy: bool = False
229-
) -> None:
230-
if freq is not None:
231-
# GH#52462
232-
warnings.warn(
233-
"The 'freq' keyword in the PeriodArray constructor is deprecated "
234-
"and will be removed in a future version. Pass 'dtype' instead",
235-
FutureWarning,
236-
stacklevel=find_stack_level(),
237-
)
238-
freq = validate_dtype_freq(dtype, freq)
239-
dtype = PeriodDtype(freq)
240-
221+
def __init__(self, values, dtype: Dtype | None = None, copy: bool = False) -> None:
241222
if dtype is not None:
242223
dtype = pandas_dtype(dtype)
243224
if not isinstance(dtype, PeriodDtype):

pandas/core/generic.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9660,13 +9660,7 @@ def _where(
96609660

96619661
# make sure we are boolean
96629662
fill_value = bool(inplace)
9663-
with warnings.catch_warnings():
9664-
warnings.filterwarnings(
9665-
"ignore",
9666-
"Downcasting object dtype arrays",
9667-
category=FutureWarning,
9668-
)
9669-
cond = cond.fillna(fill_value)
9663+
cond = cond.fillna(fill_value)
96709664
cond = cond.infer_objects()
96719665

96729666
msg = "Boolean array expected for the condition, not {dtype}"

pandas/core/interchange/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def dtype_to_arrow_c_fmt(dtype: DtypeObj) -> str:
144144
elif isinstance(dtype, DatetimeTZDtype):
145145
return ArrowCTypes.TIMESTAMP.format(resolution=dtype.unit[0], tz=dtype.tz)
146146

147+
elif isinstance(dtype, pd.BooleanDtype):
148+
return ArrowCTypes.BOOL
149+
147150
raise NotImplementedError(
148151
f"Conversion of {dtype} to Arrow C format string is not implemented."
149152
)

pandas/core/reshape/reshape.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,14 +932,18 @@ def stack_v3(frame: DataFrame, level: list[int]) -> Series | DataFrame:
932932
if len(frame.columns) == 1:
933933
data = frame.copy()
934934
else:
935-
# Take the data from frame corresponding to this idx value
936-
if len(level) == 1:
937-
idx = (idx,)
938-
gen = iter(idx)
939-
column_indexer = tuple(
940-
next(gen) if k in set_levels else slice(None)
941-
for k in range(frame.columns.nlevels)
942-
)
935+
if not isinstance(frame.columns, MultiIndex) and not isinstance(idx, tuple):
936+
# GH#57750 - if the frame is an Index with tuples, .loc below will fail
937+
column_indexer = idx
938+
else:
939+
# Take the data from frame corresponding to this idx value
940+
if len(level) == 1:
941+
idx = (idx,)
942+
gen = iter(idx)
943+
column_indexer = tuple(
944+
next(gen) if k in set_levels else slice(None)
945+
for k in range(frame.columns.nlevels)
946+
)
943947
data = frame.loc[:, column_indexer]
944948

945949
if len(level) < frame.columns.nlevels:

pandas/io/formats/xml.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
Any,
1212
final,
1313
)
14-
import warnings
1514

1615
from pandas.errors import AbstractMethodError
1716
from pandas.util._decorators import (
@@ -208,13 +207,7 @@ def _process_dataframe(self) -> dict[int | str, dict[str, Any]]:
208207
df = df.reset_index()
209208

210209
if self.na_rep is not None:
211-
with warnings.catch_warnings():
212-
warnings.filterwarnings(
213-
"ignore",
214-
"Downcasting object dtype arrays",
215-
category=FutureWarning,
216-
)
217-
df = df.fillna(self.na_rep)
210+
df = df.fillna(self.na_rep)
218211

219212
return df.to_dict(orient="index")
220213

pandas/io/json/_json.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
final,
1717
overload,
1818
)
19-
import warnings
2019

2120
import numpy as np
2221

@@ -1173,13 +1172,7 @@ def _try_convert_data(
11731172
if all(notna(data)):
11741173
return data, False
11751174

1176-
with warnings.catch_warnings():
1177-
warnings.filterwarnings(
1178-
"ignore",
1179-
"Downcasting object dtype arrays",
1180-
category=FutureWarning,
1181-
)
1182-
filled = data.fillna(np.nan)
1175+
filled = data.fillna(np.nan)
11831176

11841177
return filled, True
11851178

pandas/io/stata.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,13 +2887,7 @@ def _prepare_data(self) -> np.rec.recarray:
28872887
for i, col in enumerate(data):
28882888
typ = typlist[i]
28892889
if typ <= self._max_string_length:
2890-
with warnings.catch_warnings():
2891-
warnings.filterwarnings(
2892-
"ignore",
2893-
"Downcasting object dtype arrays",
2894-
category=FutureWarning,
2895-
)
2896-
dc = data[col].fillna("")
2890+
dc = data[col].fillna("")
28972891
data[col] = dc.apply(_pad_bytes, args=(typ,))
28982892
stype = f"S{typ}"
28992893
dtypes[col] = stype

0 commit comments

Comments
 (0)