Skip to content

Commit b767d02

Browse files
authored
Merge branch 'main' into issue-50977
2 parents fd0e408 + a254bcf commit b767d02

Some content is hidden

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

42 files changed

+160
-256
lines changed

doc/source/whatsnew/v2.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ Other API changes
620620
new DataFrame (shallow copy) instead of the original DataFrame, consistent with other
621621
methods to get a full slice (for example ``df.loc[:]`` or ``df[:]``) (:issue:`49469`)
622622
- Disallow computing ``cumprod`` for :class:`Timedelta` object; previously this returned incorrect values (:issue:`50246`)
623+
- :class:`DataFrame` objects read from a :class:`HDFStore` file without an index now have a :class:`RangeIndex` instead of an ``int64`` index (:issue:`51076`)
623624
- Instantiating an :class:`Index` with an numeric numpy dtype with data containing :class:`NA` and/or :class:`NaT` now raises a ``ValueError``. Previously a ``TypeError`` was raised (:issue:`51050`)
624625
- Loading a JSON file with duplicate columns using ``read_json(orient='split')`` renames columns to avoid duplicates, as :func:`read_csv` and the other readers do (:issue:`50370`)
625626
- The levels of the index of the :class:`Series` returned from ``Series.sparse.from_coo`` now always have dtype ``int32``. Previously they had dtype ``int64`` (:issue:`50926`)

pandas/_libs/index.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ cdef class IndexEngine:
238238
return self.unique == 1
239239

240240
cdef _do_unique_check(self):
241-
242-
# this de-facto the same
243241
self._ensure_mapping_populated()
244242

245243
@property

pandas/_libs/indexing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _IndexingMixinT = TypeVar("_IndexingMixinT", bound=IndexingMixin)
99

1010
class NDFrameIndexerBase(Generic[_IndexingMixinT]):
1111
name: str
12-
# in practise obj is either a DataFrame or a Series
12+
# in practice obj is either a DataFrame or a Series
1313
obj: _IndexingMixinT
1414

1515
def __init__(self, name: str, obj: _IndexingMixinT) -> None: ...

pandas/_libs/internals.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ from pandas._libs.util cimport (
3333
@cython.final
3434
@cython.freelist(32)
3535
cdef class BlockPlacement:
36-
# __slots__ = '_as_slice', '_as_array', '_len'
3736
cdef:
3837
slice _as_slice
3938
ndarray _as_array # Note: this still allows `None`; will be intp_t
@@ -621,7 +620,7 @@ cdef class NumpyBlock(SharedBlock):
621620
public ndarray values
622621

623622
def __cinit__(self, ndarray values, BlockPlacement placement, int ndim):
624-
# set values here the (implicit) call to SharedBlock.__cinit__ will
623+
# set values here; the (implicit) call to SharedBlock.__cinit__ will
625624
# set placement and ndim
626625
self.values = values
627626

@@ -643,7 +642,7 @@ cdef class NDArrayBackedBlock(SharedBlock):
643642
NDArrayBacked values
644643

645644
def __cinit__(self, NDArrayBacked values, BlockPlacement placement, int ndim):
646-
# set values here the (implicit) call to SharedBlock.__cinit__ will
645+
# set values here; the (implicit) call to SharedBlock.__cinit__ will
647646
# set placement and ndim
648647
self.values = values
649648

@@ -662,7 +661,7 @@ cdef class Block(SharedBlock):
662661
public object values
663662

664663
def __cinit__(self, object values, BlockPlacement placement, int ndim):
665-
# set values here the (implicit) call to SharedBlock.__cinit__ will
664+
# set values here; the (implicit) call to SharedBlock.__cinit__ will
666665
# set placement and ndim
667666
self.values = values
668667

pandas/_libs/lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def get_reverse_indexer(const intp_t[:] indexer, Py_ssize_t length) -> ndarray:
492492

493493
@cython.wraparound(False)
494494
@cython.boundscheck(False)
495-
# Can add const once https://github.com/cython/cython/issues/1772 resolved
495+
# TODO(cython3): Can add const once cython#1772 is resolved
496496
def has_infs(floating[:] arr) -> bool:
497497
cdef:
498498
Py_ssize_t i, n = len(arr)

pandas/_libs/parsers.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ from libc.string cimport (
4646

4747

4848
cdef extern from "Python.h":
49+
# TODO(cython3): get this from cpython.unicode
4950
object PyUnicode_FromString(char *v)
5051

5152

@@ -453,14 +454,12 @@ cdef class TextReader:
453454

454455
self.skipfooter = skipfooter
455456

456-
# suboptimal
457457
if usecols is not None:
458458
self.has_usecols = 1
459459
# GH-20558, validate usecols at higher level and only pass clean
460460
# usecols into TextReader.
461461
self.usecols = usecols
462462

463-
# TODO: XXX?
464463
if skipfooter > 0:
465464
self.parser.on_bad_lines = SKIP
466465

@@ -501,7 +500,6 @@ cdef class TextReader:
501500
self.dtype = dtype
502501
self.use_nullable_dtypes = use_nullable_dtypes
503502

504-
# XXX
505503
self.noconvert = set()
506504

507505
self.index_col = index_col
@@ -761,7 +759,7 @@ cdef class TextReader:
761759
# Corner case, not enough lines in the file
762760
if self.parser.lines < data_line + 1:
763761
field_count = len(header[0])
764-
else: # not self.has_usecols:
762+
else:
765763

766764
field_count = self.parser.line_fields[data_line]
767765

@@ -1409,6 +1407,8 @@ def _maybe_upcast(arr, use_nullable_dtypes: bool = False):
14091407
The casted array.
14101408
"""
14111409
if is_extension_array_dtype(arr.dtype):
1410+
# TODO: the docstring says arr is an ndarray, in which case this cannot
1411+
# be reached. Is that incorrect?
14121412
return arr
14131413

14141414
na_value = na_values[arr.dtype]

pandas/_libs/reduction.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from typing import Any
22

3-
import numpy as np
3+
from pandas._typing import DtypeObj
44

5-
from pandas._typing import ExtensionDtype
6-
7-
def check_result_array(obj: object, dtype: np.dtype | ExtensionDtype) -> None: ...
5+
def check_result_array(obj: object, dtype: DtypeObj) -> None: ...
86
def extract_result(res: object) -> Any: ...

pandas/_libs/sparse.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ cdef class BlockIndex(SparseIndex):
301301
self.nblocks = np.int32(len(self.blocs))
302302
self.npoints = self.blengths.sum()
303303

304-
# self.block_start = blocs
305-
# self.block_end = blocs + blengths
306-
307304
self.check_integrity()
308305

309306
def __reduce__(self):

pandas/_libs/sparse_op_helper.pxi.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,16 @@ cdef tuple block_op_{{opname}}_{{dtype}}({{dtype}}_t[:] x_,
137137
{{dtype}}_t[:] y_,
138138
BlockIndex yindex,
139139
{{dtype}}_t yfill):
140-
'''
140+
"""
141141
Binary operator on BlockIndex objects with fill values
142-
'''
142+
"""
143143

144144
cdef:
145145
BlockIndex out_index
146-
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
147-
int32_t xbp = 0, ybp = 0 # block positions
146+
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
147+
int32_t xbp = 0, ybp = 0 # block positions
148148
int32_t xloc, yloc
149-
Py_ssize_t xblock = 0, yblock = 0 # block numbers
149+
Py_ssize_t xblock = 0, yblock = 0 # block numbers
150150

151151
{{dtype}}_t[:] x, y
152152
ndarray[{{rdtype}}_t, ndim=1] out

pandas/_libs/tslib.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def format_array_from_datetime(
115115

116116
Parameters
117117
----------
118-
values : a 1-d i8 array
118+
values : ndarray[int64_t], arbitrary ndim
119119
tz : tzinfo or None, default None
120120
format : str or None, default None
121121
a strftime capable string
@@ -260,9 +260,9 @@ def array_with_unit_to_datetime(
260260
cdef:
261261
Py_ssize_t i, n=len(values)
262262
int64_t mult
263-
bint is_ignore = errors=="ignore"
264-
bint is_coerce = errors=="coerce"
265-
bint is_raise = errors=="raise"
263+
bint is_ignore = errors == "ignore"
264+
bint is_coerce = errors == "coerce"
265+
bint is_raise = errors == "raise"
266266
ndarray[int64_t] iresult
267267
tzinfo tz = None
268268
float fval
@@ -446,9 +446,9 @@ cpdef array_to_datetime(
446446
npy_datetimestruct dts
447447
bint utc_convert = bool(utc)
448448
bint seen_datetime_offset = False
449-
bint is_raise = errors=="raise"
450-
bint is_ignore = errors=="ignore"
451-
bint is_coerce = errors=="coerce"
449+
bint is_raise = errors == "raise"
450+
bint is_ignore = errors == "ignore"
451+
bint is_coerce = errors == "coerce"
452452
bint is_same_offsets
453453
_TSObject _ts
454454
float tz_offset

0 commit comments

Comments
 (0)