Skip to content

Commit 5829a77

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-25514
2 parents 423eea1 + e02ec8f commit 5829a77

Some content is hidden

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

45 files changed

+695
-628
lines changed

doc/source/whatsnew/v0.25.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ I/O
362362
- Bug in ``read_csv`` which would not raise ``ValueError`` if a column index in ``usecols`` was out of bounds (:issue:`25623`)
363363
- Improved the explanation for the failure when value labels are repeated in Stata dta files and suggested work-arounds (:issue:`25772`)
364364
- Improved :meth:`pandas.read_stata` and :class:`pandas.io.stata.StataReader` to read incorrectly formatted 118 format files saved by Stata (:issue:`25960`)
365+
- Fixed bug in loading objects from S3 that contain ``#`` characters in the URL (:issue:`25945`)
365366

366367
Plotting
367368
^^^^^^^^
@@ -407,6 +408,7 @@ Sparse
407408
Other
408409
^^^^^
409410

411+
- Improved :class:`Timestamp` type checking in various datetime functions to prevent exceptions when using a subclassed `datetime` (:issue:`25851`)
410412
- Bug in :class:`Series` and :class:`DataFrame` repr where ``np.datetime64('NaT')`` and ``np.timedelta64('NaT')`` with ``dtype=object`` would be represented as ``NaN`` (:issue:`25445`)
411413
-
412414
-

mypy.ini

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -140,45 +140,9 @@ ignore_errors=True
140140
[mypy-pandas.io.clipboards]
141141
ignore_errors=True
142142

143-
[mypy-pandas.io.feather_format]
144-
ignore_errors=True
145-
146-
[mypy-pandas.io.html]
147-
ignore_errors=True
148-
149-
[mypy-pandas.io.json.json]
150-
ignore_errors=True
151-
152-
[mypy-pandas.io.json.normalize]
153-
ignore_errors=True
154-
155-
[mypy-pandas.io.json.table_schema]
156-
ignore_errors=True
157-
158-
[mypy-pandas.io.packers]
159-
ignore_errors=True
160-
161-
[mypy-pandas.io.parquet]
162-
ignore_errors=True
163-
164143
[mypy-pandas.io.pytables]
165144
ignore_errors=True
166145

167-
[mypy-pandas.io.stata]
168-
ignore_errors=True
169-
170-
[mypy-pandas.plotting._core]
171-
ignore_errors=True
172-
173-
[mypy-pandas.tseries.frequencies]
174-
ignore_errors=True
175-
176-
[mypy-pandas.tseries.holiday]
177-
ignore_errors=True
178-
179-
[mypy-pandas.tseries.offsets]
180-
ignore_errors=True
181-
182146
[mypy-pandas.util._doctools]
183147
ignore_errors=True
184148

pandas/__init__.py

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
del hard_dependencies, dependency, missing_dependencies
2121

2222
# numpy compat
23-
from pandas.compat.numpy import *
23+
from pandas.compat.numpy import (
24+
_np_version_under1p14, _np_version_under1p15, _np_version_under1p16,
25+
_np_version_under1p17)
2426

2527
try:
2628
from pandas._libs import (hashtable as _hashtable,
@@ -42,14 +44,72 @@
4244
# let init-time option registration happen
4345
import pandas.core.config_init
4446

45-
from pandas.core.api import *
46-
from pandas.core.sparse.api import *
47-
from pandas.tseries.api import *
48-
from pandas.core.computation.api import *
49-
from pandas.core.reshape.api import *
47+
from pandas.core.api import (
48+
# dtype
49+
Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, UInt8Dtype,
50+
UInt16Dtype, UInt32Dtype, UInt64Dtype, CategoricalDtype,
51+
PeriodDtype, IntervalDtype, DatetimeTZDtype,
52+
53+
# missing
54+
isna, isnull, notna, notnull,
55+
56+
# indexes
57+
Index, CategoricalIndex, Int64Index, UInt64Index, RangeIndex,
58+
Float64Index, MultiIndex, IntervalIndex, TimedeltaIndex,
59+
DatetimeIndex, PeriodIndex, IndexSlice,
60+
61+
# tseries
62+
NaT, Period, period_range, Timedelta, timedelta_range,
63+
Timestamp, date_range, bdate_range, Interval, interval_range,
64+
DateOffset,
65+
66+
# conversion
67+
to_numeric, to_datetime, to_timedelta,
68+
69+
# misc
70+
np, TimeGrouper, Grouper, factorize, unique, value_counts,
71+
array, Categorical, set_eng_float_format, Series, DataFrame,
72+
Panel)
73+
74+
from pandas.core.sparse.api import (
75+
SparseArray, SparseDataFrame, SparseSeries, SparseDtype)
76+
77+
from pandas.tseries.api import infer_freq
78+
from pandas.tseries import offsets
79+
80+
from pandas.core.computation.api import eval
81+
82+
from pandas.core.reshape.api import (
83+
concat, lreshape, melt, wide_to_long, merge, merge_asof,
84+
merge_ordered, crosstab, pivot, pivot_table, get_dummies,
85+
cut, qcut)
5086

5187
from pandas.util._print_versions import show_versions
52-
from pandas.io.api import *
88+
89+
from pandas.io.api import (
90+
# excel
91+
ExcelFile, ExcelWriter, read_excel,
92+
93+
# packers
94+
read_msgpack, to_msgpack,
95+
96+
# parsers
97+
read_csv, read_fwf, read_table,
98+
99+
# pickle
100+
read_pickle, to_pickle,
101+
102+
# pytables
103+
HDFStore, read_hdf,
104+
105+
# sql
106+
read_sql, read_sql_query,
107+
read_sql_table,
108+
109+
# misc
110+
read_clipboard, read_parquet, read_feather, read_gbq,
111+
read_html, read_json, read_stata, read_sas)
112+
53113
from pandas.util._tester import test
54114
import pandas.testing
55115
import pandas.arrays

pandas/_libs/tslib.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import cython
33

44
from cpython.datetime cimport (PyDateTime_Check, PyDate_Check,
5-
PyDateTime_CheckExact,
65
PyDateTime_IMPORT,
76
timedelta, datetime, date, time)
87
# import datetime C API
@@ -19,6 +18,7 @@ import pytz
1918
from pandas._libs.util cimport (
2019
is_integer_object, is_float_object, is_datetime64_object)
2120

21+
from pandas._libs.tslibs.c_timestamp cimport _Timestamp
2222

2323
from pandas._libs.tslibs.np_datetime cimport (
2424
check_dts_bounds, npy_datetimestruct, _string_to_dts, dt64_to_dtstruct,
@@ -539,8 +539,7 @@ cpdef array_to_datetime(ndarray[object] values, str errors='raise',
539539
'datetime64 unless utc=True')
540540
else:
541541
iresult[i] = pydatetime_to_dt64(val, &dts)
542-
if not PyDateTime_CheckExact(val):
543-
# i.e. a Timestamp object
542+
if isinstance(val, _Timestamp):
544543
iresult[i] += val.nanosecond
545544
check_dts_bounds(&dts)
546545

pandas/_libs/tslibs/c_timestamp.pxd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from cpython.datetime cimport datetime
4+
5+
from numpy cimport int64_t
6+
7+
cdef class _Timestamp(datetime):
8+
cdef readonly:
9+
int64_t value, nanosecond
10+
object freq
11+
list _date_attributes
12+
cpdef bint _get_start_end_field(self, str field)
13+
cpdef _get_date_name_field(self, object field, object locale)
14+
cdef int64_t _maybe_convert_value_to_local(self)
15+
cpdef to_datetime64(self)
16+
cdef _assert_tzawareness_compat(_Timestamp self, datetime other)
17+
cpdef datetime to_pydatetime(_Timestamp self, bint warn=*)
18+
cdef bint _compare_outside_nanorange(_Timestamp self, datetime other,
19+
int op) except -1

0 commit comments

Comments
 (0)