Skip to content

Commit 0a4e835

Browse files
Merge remote-tracking branch 'upstream/master' into boilerplate-4
2 parents 9ced7d4 + 08febd2 commit 0a4e835

File tree

91 files changed

+967
-1138
lines changed

Some content is hidden

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

91 files changed

+967
-1138
lines changed

ci/deps/azure-37-locale.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ dependencies:
55
- python=3.7.*
66

77
# tools
8-
- cython>=0.29.16
8+
# Cython pin for https://github.com/pandas-dev/pandas/issues/34704
9+
- cython==0.29.19
910
- pytest>=5.0.1
1011
- pytest-xdist>=1.21
1112
- pytest-asyncio

doc/source/development/contributing.rst

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ want to clone your fork to your machine::
136136
This creates the directory `pandas-yourname` and connects your repository to
137137
the upstream (main project) *pandas* repository.
138138

139+
Note that performing a shallow clone (with ``--depth==N``, for some ``N`` greater
140+
or equal to 1) might break some tests and features as ``pd.show_versions()``
141+
as the version number cannot be computed anymore.
142+
139143
.. _contributing.dev_env:
140144

141145
Creating a development environment

doc/source/user_guide/merging.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ columns:
12731273
12741274
.. ipython:: python
12751275
1276-
result = pd.merge(left, right, on='k', suffixes=['_l', '_r'])
1276+
result = pd.merge(left, right, on='k', suffixes=('_l', '_r'))
12771277
12781278
.. ipython:: python
12791279
:suppress:

doc/source/user_guide/visualization.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ otherwise you will see a warning.
13321332

13331333
.. ipython:: python
13341334
1335-
fig, axes = plt.subplots(4, 4, figsize=(6, 6))
1335+
fig, axes = plt.subplots(4, 4, figsize=(9, 9))
13361336
plt.subplots_adjust(wspace=0.5, hspace=0.5)
13371337
target1 = [axes[0][0], axes[1][1], axes[2][2], axes[3][3]]
13381338
target2 = [axes[3][0], axes[2][1], axes[1][2], axes[0][3]]
@@ -1369,6 +1369,7 @@ Another option is passing an ``ax`` argument to :meth:`Series.plot` to plot on a
13691369
.. ipython:: python
13701370
13711371
fig, axes = plt.subplots(nrows=2, ncols=2)
1372+
plt.subplots_adjust(wspace=0.2, hspace=0.5)
13721373
df['A'].plot(ax=axes[0, 0]);
13731374
axes[0, 0].set_title('A');
13741375
df['B'].plot(ax=axes[0, 1]);

doc/source/whatsnew/v1.0.5.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Fixed regressions
2222

2323
Bug fixes
2424
~~~~~~~~~
25-
-
25+
26+
- Fixed building from source with Python 3.8 fetching the wrong version of NumPy (:issue:`34666`)
2627
-
2728

2829
Contributors

doc/source/whatsnew/v1.1.0.rst

+7
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ Other enhancements
288288
- :meth:`HDFStore.put` now accepts `track_times` parameter. Parameter is passed to ``create_table`` method of ``PyTables`` (:issue:`32682`).
289289
- Make :class:`pandas.core.window.Rolling` and :class:`pandas.core.window.Expanding` iterable(:issue:`11704`)
290290
- Make ``option_context`` a :class:`contextlib.ContextDecorator`, which allows it to be used as a decorator over an entire function (:issue:`34253`).
291+
- :meth:`DataFrame.to_csv` and :meth:`Series.to_csv` now accept an ``errors`` argument (:issue:`22610`)
291292
- :meth:`groupby.transform` now allows ``func`` to be ``pad``, ``backfill`` and ``cumcount`` (:issue:`31269`).
292293
- :meth:`~pandas.io.json.read_json` now accepts `nrows` parameter. (:issue:`33916`).
293294
- :meth `~pandas.io.gbq.read_gbq` now allows to disable progress bar (:issue:`33360`).
295+
- :meth:`~pandas.io.gbq.read_gbq` now supports the ``max_results`` kwarg from ``pandas-gbq`` (:issue:`34639`).
294296

295297
.. ---------------------------------------------------------------------------
296298
@@ -401,6 +403,8 @@ Backwards incompatible API changes
401403
- :func: `pandas.api.dtypes.is_string_dtype` no longer incorrectly identifies categorical series as string.
402404
- :func:`read_excel` no longer takes ``**kwds`` arguments. This means that passing in keyword ``chunksize`` now raises a ``TypeError``
403405
(previously raised a ``NotImplementedError``), while passing in keyword ``encoding`` now raises a ``TypeError`` (:issue:`34464`)
406+
- :func: `merge` now checks ``suffixes`` parameter type to be ``tuple`` and raises ``TypeError``, whereas before a ``list`` or ``set`` were accepted and that the ``set`` could produce unexpected results (:issue:`33740`)
407+
- :class:`Period` no longer accepts tuples for the ``freq`` argument (:issue:`34658`)
404408

405409
``MultiIndex.get_indexer`` interprets `method` argument differently
406410
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -826,6 +830,7 @@ Timedelta
826830
- Bug in :func:`timedelta_range` that produced an extra point on a edge case (:issue:`30353`, :issue:`33498`)
827831
- Bug in :meth:`DataFrame.resample` that produced an extra point on a edge case (:issue:`30353`, :issue:`13022`, :issue:`33498`)
828832
- Bug in :meth:`DataFrame.resample` that ignored the ``loffset`` argument when dealing with timedelta (:issue:`7687`, :issue:`33498`)
833+
- Bug in :class:`Timedelta` and `pandas.to_timedelta` that ignored `unit`-argument for string input (:issue:`12136`)
829834

830835
Timezones
831836
^^^^^^^^^
@@ -892,6 +897,7 @@ Indexing
892897
- Bug in :meth:`DataFrame.truncate` and :meth:`Series.truncate` where index was assumed to be monotone increasing (:issue:`33756`)
893898
- Indexing with a list of strings representing datetimes failed on :class:`DatetimeIndex` or :class:`PeriodIndex`(:issue:`11278`)
894899
- Bug in :meth:`Series.at` when used with a :class:`MultiIndex` would raise an exception on valid inputs (:issue:`26989`)
900+
- Bug in :meth:`DataFrame.loc` with dictionary of values changes columns with dtype of ``int`` to ``float`` (:issue:`34573`)
895901
- Bug in :meth:`Series.loc` when used with a :class:`MultiIndex` would raise an IndexingError when accessing a None value (:issue:`34318`)
896902

897903
Missing
@@ -1012,6 +1018,7 @@ Reshaping
10121018
- Ensure only named functions can be used in :func:`eval()` (:issue:`32460`)
10131019
- Bug in :func:`Dataframe.aggregate` and :func:`Series.aggregate` was causing recursive loop in some cases (:issue:`34224`)
10141020
- Fixed bug in :func:`melt` where melting MultiIndex columns with ``col_level`` > 0 would raise a ``KeyError`` on ``id_vars`` (:issue:`34129`)
1021+
- Bug in :meth:`Series.where` with an empty Series and empty ``cond`` having non-bool dtype (:issue:`34592`)
10151022

10161023
Sparse
10171024
^^^^^^

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- asv
1313

1414
# building
15-
- cython>=0.29.16
15+
- cython=0.29.19
1616

1717
# code checks
1818
- black=19.10b0

pandas/_libs/tslibs/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__all__ = [
2+
"dtypes",
23
"localize_pydatetime",
34
"NaT",
45
"NaTType",
@@ -17,7 +18,7 @@
1718
"to_offset",
1819
]
1920

20-
21+
from . import dtypes
2122
from .conversion import localize_pydatetime
2223
from .nattype import NaT, NaTType, iNaT, is_null_datetimelike, nat_strings
2324
from .np_datetime import OutOfBoundsDatetime

pandas/_libs/tslibs/conversion.pyx

+15-20
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ cpdef ndarray[int64_t] normalize_i8_timestamps(const int64_t[:] stamps, tzinfo t
785785
int64_t[:] deltas
786786
str typ
787787
Py_ssize_t[:] pos
788-
npy_datetimestruct dts
789788
int64_t delta, local_val
790789

791790
if tz is None or is_utc(tz):
@@ -795,16 +794,14 @@ cpdef ndarray[int64_t] normalize_i8_timestamps(const int64_t[:] stamps, tzinfo t
795794
result[i] = NPY_NAT
796795
continue
797796
local_val = stamps[i]
798-
dt64_to_dtstruct(local_val, &dts)
799-
result[i] = _normalized_stamp(&dts)
797+
result[i] = _normalize_i8_stamp(local_val)
800798
elif is_tzlocal(tz):
801799
for i in range(n):
802800
if stamps[i] == NPY_NAT:
803801
result[i] = NPY_NAT
804802
continue
805803
local_val = tz_convert_utc_to_tzlocal(stamps[i], tz)
806-
dt64_to_dtstruct(local_val, &dts)
807-
result[i] = _normalized_stamp(&dts)
804+
result[i] = _normalize_i8_stamp(local_val)
808805
else:
809806
# Adjust datetime64 timestamp, recompute datetimestruct
810807
trans, deltas, typ = get_dst_info(tz)
@@ -816,38 +813,36 @@ cpdef ndarray[int64_t] normalize_i8_timestamps(const int64_t[:] stamps, tzinfo t
816813
if stamps[i] == NPY_NAT:
817814
result[i] = NPY_NAT
818815
continue
819-
dt64_to_dtstruct(stamps[i] + delta, &dts)
820-
result[i] = _normalized_stamp(&dts)
816+
local_val = stamps[i] + delta
817+
result[i] = _normalize_i8_stamp(local_val)
821818
else:
822819
pos = trans.searchsorted(stamps, side='right') - 1
823820
for i in range(n):
824821
if stamps[i] == NPY_NAT:
825822
result[i] = NPY_NAT
826823
continue
827-
dt64_to_dtstruct(stamps[i] + deltas[pos[i]], &dts)
828-
result[i] = _normalized_stamp(&dts)
824+
local_val = stamps[i] + deltas[pos[i]]
825+
result[i] = _normalize_i8_stamp(local_val)
829826

830827
return result.base # `.base` to access underlying ndarray
831828

832829

833-
cdef inline int64_t _normalized_stamp(npy_datetimestruct *dts) nogil:
830+
@cython.cdivision
831+
cdef inline int64_t _normalize_i8_stamp(int64_t local_val) nogil:
834832
"""
835-
Normalize the given datetimestruct to midnight, then convert to int64_t.
833+
Round the localized nanosecond timestamp down to the previous midnight.
836834
837835
Parameters
838836
----------
839-
*dts : pointer to npy_datetimestruct
837+
local_val : int64_t
840838
841839
Returns
842840
-------
843-
stamp : int64
844-
"""
845-
dts.hour = 0
846-
dts.min = 0
847-
dts.sec = 0
848-
dts.us = 0
849-
dts.ps = 0
850-
return dtstruct_to_dt64(dts)
841+
int64_t
842+
"""
843+
cdef:
844+
int64_t day_nanos = 24 * 3600 * 1_000_000_000
845+
return local_val - (local_val % day_nanos)
851846

852847

853848
@cython.wraparound(False)

pandas/_libs/tslibs/dtypes.pxd

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11

2+
cdef enum c_FreqGroup:
3+
# Mirrors FreqGroup in the .pxy file
4+
FR_ANN = 1000
5+
FR_QTR = 2000
6+
FR_MTH = 3000
7+
FR_WK = 4000
8+
FR_BUS = 5000
9+
FR_DAY = 6000
10+
FR_HR = 7000
11+
FR_MIN = 8000
12+
FR_SEC = 9000
13+
FR_MS = 10000
14+
FR_US = 11000
15+
FR_NS = 12000
16+
FR_UND = -10000 # undefined
17+
18+
219
cdef enum PeriodDtypeCode:
320
# Annual freqs with various fiscal year ends.
421
# eg, 2005 for A_FEB runs Mar 1, 2004 to Feb 28, 2005
@@ -50,7 +67,9 @@ cdef enum PeriodDtypeCode:
5067
U = 11000 # Microsecondly
5168
N = 12000 # Nanosecondly
5269

70+
UNDEFINED = -10_000
71+
5372

54-
cdef class PeriodPseudoDtype:
73+
cdef class PeriodDtypeBase:
5574
cdef readonly:
5675
PeriodDtypeCode dtype_code

pandas/_libs/tslibs/dtypes.pyx

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# originals
33

44

5-
cdef class PeriodPseudoDtype:
5+
cdef class PeriodDtypeBase:
66
"""
77
Similar to an actual dtype, this contains all of the information
88
describing a PeriodDtype in an integer code.
@@ -14,9 +14,9 @@ cdef class PeriodPseudoDtype:
1414
self.dtype_code = code
1515

1616
def __eq__(self, other):
17-
if not isinstance(other, PeriodPseudoDtype):
17+
if not isinstance(other, PeriodDtypeBase):
1818
return False
19-
if not isinstance(self, PeriodPseudoDtype):
19+
if not isinstance(self, PeriodDtypeBase):
2020
# cython semantics, this is a reversed op
2121
return False
2222
return self.dtype_code == other.dtype_code
@@ -106,3 +106,20 @@ _period_code_map.update({
106106
"W": 4000, # Weekly
107107
"C": 5000, # Custom Business Day
108108
})
109+
110+
111+
class FreqGroup:
112+
# Mirrors c_FreqGroup in the .pxd file
113+
FR_ANN = 1000
114+
FR_QTR = 2000
115+
FR_MTH = 3000
116+
FR_WK = 4000
117+
FR_BUS = 5000
118+
FR_DAY = 6000
119+
FR_HR = 7000
120+
FR_MIN = 8000
121+
FR_SEC = 9000
122+
FR_MS = 10000
123+
FR_US = 11000
124+
FR_NS = 12000
125+
FR_UND = -10000 # undefined

pandas/_libs/tslibs/frequencies.pxd

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
cdef dict attrname_to_abbrevs
22

3-
cpdef get_freq_code(freqstr)
43
cpdef int get_to_timestamp_base(int base)
5-
cpdef str get_freq_str(base, mult=*)

0 commit comments

Comments
 (0)