Skip to content

Commit ea23d74

Browse files
author
Wang Haoxiang
authored
Merge branch 'main' into main
2 parents 17d83b3 + e0398c4 commit ea23d74

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

pandas/io/sas/sas_xport.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import numpy as np
1919

20-
from pandas.util._decorators import Appender
2120
from pandas.util._exceptions import find_stack_level
2221

2322
import pandas as pd
@@ -126,20 +125,6 @@
126125
Contains information about the variables in the file
127126
"""
128127

129-
_read_method_doc = """\
130-
Read observations from SAS Xport file, returning as data frame.
131-
132-
Parameters
133-
----------
134-
nrows : int
135-
Number of rows to read from data file; if None, read whole
136-
file.
137-
138-
Returns
139-
-------
140-
A DataFrame.
141-
"""
142-
143128

144129
def _parse_date(datestr: str) -> DatetimeNaTType:
145130
"""Given a date in xport format, return Python date."""
@@ -464,8 +449,19 @@ def _missing_double(self, vec):
464449
miss &= miss1
465450
return miss
466451

467-
@Appender(_read_method_doc)
468452
def read(self, nrows: int | None = None) -> pd.DataFrame:
453+
"""Read observations from SAS Xport file, returning as data frame.
454+
455+
Parameters
456+
----------
457+
nrows : int
458+
Number of rows to read from data file; if None, read whole
459+
file.
460+
461+
Returns
462+
-------
463+
A DataFrame.
464+
"""
469465
if nrows is None:
470466
nrows = self.nobs
471467

pandas/tests/indexing/test_loc.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,25 @@ def test_loc_getitem_single_boolean_arg(self, obj, key, exp):
258258
else:
259259
assert res == exp
260260

261+
@pytest.mark.parametrize(
262+
"data",
263+
[
264+
[datetime(2025, 10, 30)],
265+
[Timestamp(2025, 10, 30)] * 2,
266+
[Timedelta(1)],
267+
[Timedelta(1), Timedelta(2)],
268+
],
269+
)
270+
def test_loc_empty_slice_assignment_with_datetime(self, data):
271+
# issue #50942
272+
# empty slice assignment with datetime or timedelta should not raise exceptions
273+
mask = [False] * len(data)
274+
275+
df = DataFrame(data=data, columns=["A"])
276+
expected = df.copy()
277+
df.loc[mask] = df
278+
tm.assert_frame_equal(df, expected)
279+
261280

262281
class TestLocBaseIndependent:
263282
# Tests for loc that do not depend on subclassing Base

0 commit comments

Comments
 (0)