Skip to content

Commit 5fffb5d

Browse files
authored
Merge pull request #86 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 8dba430 + 7fa8ee7 commit 5fffb5d

Some content is hidden

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

67 files changed

+1577
-1368
lines changed

doc/redirects.csv

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,25 @@ internals,development/internals
4949
# api moved function
5050
reference/api/pandas.io.json.json_normalize,pandas.json_normalize
5151

52-
# api rename
52+
# rename due to refactors
53+
reference/api/pandas.core.window.Rolling,pandas.core.window.rolling.Rolling
54+
reference/api/pandas.core.window.Rolling.aggregate,pandas.core.window.rolling.Rolling.aggregate
55+
reference/api/pandas.core.window.Rolling.apply,pandas.core.window.rolling.Rolling.apply
56+
reference/api/pandas.core.window.Rolling.corr,pandas.core.window.rolling.Rolling.corr
57+
reference/api/pandas.core.window.Rolling.count,pandas.core.window.rolling.Rolling.count
58+
reference/api/pandas.core.window.Rolling.cov,pandas.core.window.rolling.Rolling.cov
59+
reference/api/pandas.core.window.Rolling.kurt,pandas.core.window.rolling.Rolling.kurt
60+
reference/api/pandas.core.window.Rolling.max,pandas.core.window.rolling.Rolling.max
61+
reference/api/pandas.core.window.Rolling.mean,pandas.core.window.rolling.Rolling.mean
62+
reference/api/pandas.core.window.Rolling.median,pandas.core.window.rolling.Rolling.median
63+
reference/api/pandas.core.window.Rolling.min,pandas.core.window.rolling.Rolling.min
64+
reference/api/pandas.core.window.Rolling.quantile,pandas.core.window.rolling.Rolling.quantile
65+
reference/api/pandas.core.window.Rolling.skew,pandas.core.window.rolling.Rolling.skew
66+
reference/api/pandas.core.window.Rolling.std,pandas.core.window.rolling.Rolling.std
67+
reference/api/pandas.core.window.Rolling.sum,pandas.core.window.rolling.Rolling.sum
68+
reference/api/pandas.core.window.Rolling.var,pandas.core.window.rolling.Rolling.var
69+
70+
# api url change (generated -> reference/api rename)
5371
api,reference/index
5472
generated/pandas.api.extensions.ExtensionArray.argsort,../reference/api/pandas.api.extensions.ExtensionArray.argsort
5573
generated/pandas.api.extensions.ExtensionArray.astype,../reference/api/pandas.api.extensions.ExtensionArray.astype
Lines changed: 72 additions & 0 deletions
Loading

doc/source/development/meeting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This calendar shows all the developer meetings.
2525
You can subscribe to this calendar with the following links:
2626

2727
* `iCal <https://calendar.google.com/calendar/ical/pgbn14p6poja8a1cf2dv2jhrmg%40group.calendar.google.com/public/basic.ics>`__
28-
* `Google calendar <https://calendar.google.com/calendar/embed?src=pgbn14p6poja8a1cf2dv2jhrmg%40group.calendar.google.com>`__
28+
* `Google calendar <https://calendar.google.com/calendar/r?cid=pgbn14p6poja8a1cf2dv2jhrmg@group.calendar.google.com>`__
2929

3030
Additionally, we'll sometimes have one-off meetings on specific topics.
3131
These will be published on the same calendar.

doc/source/whatsnew/v1.0.2.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _whatsnew_102:
22

3-
What's new in 1.0.2 (February ??, 2020)
4-
---------------------------------------
3+
What's new in 1.0.2 (March 11, 2020)
4+
------------------------------------
55

66
These are the changes in pandas 1.0.2. See :ref:`release` for a full changelog
77
including other versions of pandas.
@@ -18,13 +18,14 @@ Fixed regressions
1818
- Fixed regression in :meth:`DataFrame.to_excel` when ``columns`` kwarg is passed (:issue:`31677`)
1919
- Fixed regression in :meth:`Series.align` when ``other`` is a DataFrame and ``method`` is not None (:issue:`31785`)
2020
- Fixed regression in :meth:`pandas.core.groupby.RollingGroupby.apply` where the ``raw`` parameter was ignored (:issue:`31754`)
21-
- Fixed regression in :meth:`rolling(..).corr() <pandas.core.window.Rolling.corr>` when using a time offset (:issue:`31789`)
22-
- Fixed regression in :meth:`DataFrameGroupBy.nunique` which was modifying the original values if ``NaN`` values were present (:issue:`31950`)
21+
- Fixed regression in :meth:`pandas.core.window.Rolling.corr` when using a time offset (:issue:`31789`)
22+
- Fixed regression in :meth:`pandas.core.groupby.DataFrameGroupBy.nunique` which was modifying the original values if ``NaN`` values were present (:issue:`31950`)
2323
- Fixed regression where :func:`read_pickle` raised a ``UnicodeDecodeError`` when reading a py27 pickle with :class:`MultiIndex` column (:issue:`31988`).
2424
- Fixed regression in :class:`DataFrame` arithmetic operations with mis-matched columns (:issue:`31623`)
25-
- Fixed regression in :meth:`GroupBy.agg` calling a user-provided function an extra time on an empty input (:issue:`31760`)
25+
- Fixed regression in :meth:`pandas.core.groupby.GroupBy.agg` calling a user-provided function an extra time on an empty input (:issue:`31760`)
2626
- Joining on :class:`DatetimeIndex` or :class:`TimedeltaIndex` will preserve ``freq`` in simple cases (:issue:`32166`)
27-
- Fixed bug in the repr of an object-dtype ``Index`` with bools and missing values (:issue:`32146`)
27+
- Fixed bug in the repr of an object-dtype :class:`Index` with bools and missing values (:issue:`32146`)
28+
- Fixed regression in :meth:`read_csv` in which the ``encoding`` option was not recognized with certain file-like objects (:issue:`31819`)
2829
-
2930

3031
.. ---------------------------------------------------------------------------
@@ -64,7 +65,9 @@ Bug fixes
6465
**Datetimelike**
6566

6667
- Bug in :meth:`DataFrame.reindex` and :meth:`Series.reindex` when reindexing with a tz-aware index (:issue:`26683`)
68+
- Bug in :meth:`Series.astype` not copying for tz-naive and tz-aware datetime64 dtype (:issue:`32490`)
6769
- Bug where :func:`to_datetime` would raise when passed ``pd.NA`` (:issue:`32213`)
70+
- Improved error message when subtracting two :class:`Timestamp` that result in an out-of-bounds :class:`Timedelta` (:issue:`31774`)
6871

6972
**Categorical**
7073

@@ -82,8 +85,17 @@ Bug fixes
8285

8386
- Fix bug in :meth:`DataFrame.convert_dtypes` for columns that were already using the ``"string"`` dtype (:issue:`31731`).
8487
- Fixed bug in setting values using a slice indexer with string dtype (:issue:`31772`)
85-
- Fixed bug where :meth:`GroupBy.first` and :meth:`GroupBy.last` would raise a ``TypeError`` when groups contained ``pd.NA`` in a column of object dtype (:issue:`32123`)
88+
- Fixed bug where :meth:`pandas.core.groupby.GroupBy.first` and :meth:`pandas.core.groupby.GroupBy.last` would raise a ``TypeError`` when groups contained ``pd.NA`` in a column of object dtype (:issue:`32123`)
8689
- Fix bug in :meth:`Series.convert_dtypes` for series with mix of integers and strings (:issue:`32117`)
90+
- Fixed bug in :meth:`DataFrame.convert_dtypes`, where ``BooleanDtype`` columns were converted to ``Int64`` (:issue:`32287`)
91+
92+
**Strings**
93+
94+
- Using ``pd.NA`` with :meth:`Series.str.repeat` now correctly outputs a null value instead of raising error for vector inputs (:issue:`31632`)
95+
96+
**Rolling**
97+
98+
- Fixed rolling operations with variable window (defined by time duration) on decreasing time index (:issue:`32385`).
8799

88100
.. ---------------------------------------------------------------------------
89101

doc/source/whatsnew/v1.1.0.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Other enhancements
6464
^^^^^^^^^^^^^^^^^^
6565

6666
- :class:`Styler` may now render CSS more efficiently where multiple cells have the same styling (:issue:`30876`)
67+
- :meth:`Styler.highlight_null` now accepts ``subset`` argument (:issue:`31345`)
6768
- When writing directly to a sqlite connection :func:`to_sql` now supports the ``multi`` method (:issue:`29921`)
6869
- `OptionError` is now exposed in `pandas.errors` (:issue:`27553`)
6970
- :func:`timedelta_range` will now infer a frequency when passed ``start``, ``stop``, and ``periods`` (:issue:`32377`)
@@ -187,7 +188,9 @@ Performance improvements
187188
- Performance improvement in :class:`Timedelta` constructor (:issue:`30543`)
188189
- Performance improvement in :class:`Timestamp` constructor (:issue:`30543`)
189190
- Performance improvement in flex arithmetic ops between :class:`DataFrame` and :class:`Series` with ``axis=0`` (:issue:`31296`)
190-
-
191+
- The internal :meth:`Index._shallow_copy` now copies cached attributes over to the new index,
192+
avoiding creating these again on the new index. This can speed up many operations
193+
that depend on creating copies of existing indexes (:issue:`28584`)
191194

192195
.. ---------------------------------------------------------------------------
193196
@@ -262,7 +265,7 @@ Indexing
262265
- Bug in :meth:`Series.xs` incorrectly returning ``Timestamp`` instead of ``datetime64`` in some object-dtype cases (:issue:`31630`)
263266
- Bug in :meth:`DataFrame.iat` incorrectly returning ``Timestamp`` instead of ``datetime`` in some object-dtype cases (:issue:`32809`)
264267
- Bug in :meth:`Series.loc` and :meth:`DataFrame.loc` when indexing with an integer key on a object-dtype :class:`Index` that is not all-integers (:issue:`31905`)
265-
-
268+
- Bug in :meth:`DataFrame.iloc.__setitem__` on a :class:`DataFrame` with duplicate columns incorrectly setting values for all matching columns (:issue:`15686`, :issue:`22036`)
266269

267270
Missing
268271
^^^^^^^

pandas/_libs/parsers.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ cdef class TextReader:
638638
raise ValueError(f'Unrecognized compression type: '
639639
f'{self.compression}')
640640

641-
if self.encoding and isinstance(source, (io.BufferedIOBase, io.RawIOBase)):
641+
if (self.encoding and hasattr(source, "read") and
642+
not hasattr(source, "encoding")):
642643
source = io.TextIOWrapper(
643644
source, self.encoding.decode('utf-8'), newline='')
644645

pandas/_libs/src/ujson/python/objToJSON.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ static PyObject *get_values(PyObject *obj) {
237237
}
238238
}
239239

240-
if ((values == NULL) && PyObject_HasAttrString(obj, "get_block_values")) {
240+
if ((values == NULL) && PyObject_HasAttrString(obj, "get_block_values_for_json")) {
241241
PRINTMARK();
242-
values = PyObject_CallMethod(obj, "get_block_values", NULL);
242+
values = PyObject_CallMethod(obj, "get_block_values_for_json", NULL);
243243

244244
if (values == NULL) {
245245
// Clear so we can subsequently try another method

pandas/_libs/tslibs/c_timestamp.pyx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ cdef class _Timestamp(datetime):
286286
# coerce if necessary if we are a Timestamp-like
287287
if (PyDateTime_Check(self)
288288
and (PyDateTime_Check(other) or is_datetime64_object(other))):
289+
# both_timestamps is to determine whether Timedelta(self - other)
290+
# should raise the OOB error, or fall back returning a timedelta.
291+
both_timestamps = (isinstance(other, _Timestamp) and
292+
isinstance(self, _Timestamp))
289293
if isinstance(self, _Timestamp):
290294
other = type(self)(other)
291295
else:
@@ -301,7 +305,14 @@ cdef class _Timestamp(datetime):
301305
from pandas._libs.tslibs.timedeltas import Timedelta
302306
try:
303307
return Timedelta(self.value - other.value)
304-
except (OverflowError, OutOfBoundsDatetime):
308+
except (OverflowError, OutOfBoundsDatetime) as err:
309+
if isinstance(other, _Timestamp):
310+
if both_timestamps:
311+
raise OutOfBoundsDatetime(
312+
"Result is too large for pandas.Timedelta. Convert inputs "
313+
"to datetime.datetime with 'Timestamp.to_pydatetime()' "
314+
"before subtracting."
315+
) from err
305316
pass
306317
elif is_datetime64_object(self):
307318
# GH#28286 cython semantics for __rsub__, `other` is actually

pandas/_libs/window/aggregations.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ def roll_max_variable(ndarray[float64_t] values, ndarray[int64_t] start,
10131013
def roll_min_fixed(ndarray[float64_t] values, ndarray[int64_t] start,
10141014
ndarray[int64_t] end, int64_t minp, int64_t win):
10151015
"""
1016-
Moving max of 1d array of any numeric type along axis=0 ignoring NaNs.
1016+
Moving min of 1d array of any numeric type along axis=0 ignoring NaNs.
10171017
10181018
Parameters
10191019
----------
@@ -1030,7 +1030,7 @@ def roll_min_fixed(ndarray[float64_t] values, ndarray[int64_t] start,
10301030
def roll_min_variable(ndarray[float64_t] values, ndarray[int64_t] start,
10311031
ndarray[int64_t] end, int64_t minp):
10321032
"""
1033-
Moving max of 1d array of any numeric type along axis=0 ignoring NaNs.
1033+
Moving min of 1d array of any numeric type along axis=0 ignoring NaNs.
10341034
10351035
Parameters
10361036
----------

pandas/_libs/window/indexers.pyx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def calculate_variable_window_bounds(
4444
cdef:
4545
bint left_closed = False
4646
bint right_closed = False
47+
int index_growth_sign = 1
4748
ndarray[int64_t, ndim=1] start, end
4849
int64_t start_bound, end_bound
4950
Py_ssize_t i, j
@@ -58,6 +59,9 @@ def calculate_variable_window_bounds(
5859
if closed in ['left', 'both']:
5960
left_closed = True
6061

62+
if index[num_values - 1] < index[0]:
63+
index_growth_sign = -1
64+
6165
start = np.empty(num_values, dtype='int64')
6266
start.fill(-1)
6367
end = np.empty(num_values, dtype='int64')
@@ -78,7 +82,7 @@ def calculate_variable_window_bounds(
7882
# end is end of slice interval (not including)
7983
for i in range(1, num_values):
8084
end_bound = index[i]
81-
start_bound = index[i] - window_size
85+
start_bound = index[i] - index_growth_sign * window_size
8286

8387
# left endpoint is closed
8488
if left_closed:
@@ -88,13 +92,13 @@ def calculate_variable_window_bounds(
8892
# within the constraint
8993
start[i] = i
9094
for j in range(start[i - 1], i):
91-
if index[j] > start_bound:
95+
if (index[j] - start_bound) * index_growth_sign > 0:
9296
start[i] = j
9397
break
9498

9599
# end bound is previous end
96100
# or current index
97-
if index[end[i - 1]] <= end_bound:
101+
if (index[end[i - 1]] - end_bound) * index_growth_sign <= 0:
98102
end[i] = i + 1
99103
else:
100104
end[i] = end[i - 1]

0 commit comments

Comments
 (0)