Skip to content

Commit 5d63447

Browse files
committed
Merge branch 'master' into misc/remove-docs
2 parents b5c6b6b + 126bb92 commit 5d63447

File tree

84 files changed

+1333
-1055
lines changed

Some content is hidden

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

84 files changed

+1333
-1055
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ jobs:
169169
pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_frame_setitem_multi_column
170170
171171
pytest pandas/tests/api/
172+
pytest pandas/tests/apply/
172173
pytest pandas/tests/arrays/
173174
pytest pandas/tests/base/
174175
pytest pandas/tests/computation/

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ minimum_pre_commit_version: 2.9.2
22
exclude: ^LICENSES/|\.(html|csv|svg)$
33
repos:
44
- repo: https://github.com/MarcoGorelli/absolufy-imports
5-
rev: v0.2.1
5+
rev: v0.3.0
66
hooks:
77
- id: absolufy-imports
88
files: ^pandas/
@@ -33,7 +33,7 @@ repos:
3333
exclude: ^pandas/_libs/src/(klib|headers)/
3434
args: [--quiet, '--extensions=c,h', '--headers=h', --recursive, '--filter=-readability/casting,-runtime/int,-build/include_subdir']
3535
- repo: https://gitlab.com/pycqa/flake8
36-
rev: 3.8.4
36+
rev: 3.9.0
3737
hooks:
3838
- id: flake8
3939
additional_dependencies: [flake8-comprehensions>=3.1.0]

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY : develop build clean clean_pyc doc lint-diff black
1+
.PHONY : develop build clean clean_pyc doc lint-diff black test-scripts
22

33
all: develop
44

@@ -25,3 +25,6 @@ doc:
2525
cd doc; \
2626
python make.py clean; \
2727
python make.py html
28+
29+
test-scripts:
30+
pytest scripts

doc/source/user_guide/window.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ parameter:
168168
============= ====================
169169
Value Behavior
170170
============= ====================
171-
``right'`` close right endpoint
171+
``'right'`` close right endpoint
172172
``'left'`` close left endpoint
173173
``'both'`` close both endpoints
174174
``'neither'`` open endpoints
@@ -214,7 +214,7 @@ ending indices of the windows. Additionally, ``num_values``, ``min_periods``, ``
214214
and will automatically be passed to ``get_window_bounds`` and the defined method must
215215
always accept these arguments.
216216

217-
For example, if we have the following :class:``DataFrame``:
217+
For example, if we have the following :class:`DataFrame`
218218

219219
.. ipython:: python
220220
@@ -370,8 +370,8 @@ two :class:`Series` or any combination of :class:`DataFrame`/:class:`Series` or
370370
with the passed Series, thus returning a DataFrame.
371371
* :class:`DataFrame`/:class:`DataFrame`: by default compute the statistic for matching column
372372
names, returning a DataFrame. If the keyword argument ``pairwise=True`` is
373-
passed then computes the statistic for each pair of columns, returning a
374-
``MultiIndexed DataFrame`` whose ``index`` are the dates in question (see :ref:`the next section
373+
passed then computes the statistic for each pair of columns, returning a :class:`DataFrame` with a
374+
:class:`MultiIndex` whose values are the dates in question (see :ref:`the next section
375375
<window.corr_pairwise>`).
376376

377377
For example:

doc/source/whatsnew/v1.3.0.rst

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,41 @@ In pandas 1.3.0, ``df`` continues to share data with ``values``
225225
np.shares_memory(df["A"], values)
226226
227227
228+
.. _whatsnew_130.notable_bug_fixes.setitem_never_inplace:
229+
230+
Never Operate Inplace When Setting ``frame[keys] = values``
231+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
232+
233+
When setting multiple columns using ``frame[keys] = values`` new arrays will
234+
replace pre-existing arrays for these keys, which will *not* be over-written
235+
(:issue:`39510`). As a result, the columns will retain the dtype(s) of ``values``,
236+
never casting to the dtypes of the existing arrays.
237+
238+
.. ipython:: python
239+
240+
df = pd.DataFrame(range(3), columns=["A"], dtype="float64")
241+
df[["A"]] = 5
242+
243+
In the old behavior, ``5`` was cast to ``float64`` and inserted into the existing
244+
array backing ``df``:
245+
246+
*pandas 1.2.x*
247+
248+
.. code-block:: ipython
249+
250+
In [1]: df.dtypes
251+
Out[1]:
252+
A float64
253+
254+
In the new behavior, we get a new array, and retain an integer-dtyped ``5``:
255+
256+
*pandas 1.3.0*
257+
258+
.. ipython:: python
259+
260+
df.dtypes
261+
262+
228263
.. _whatsnew_130.notable_bug_fixes.setitem_with_bool_casting:
229264

230265
Consistent Casting With Setting Into Boolean Series
@@ -300,7 +335,7 @@ Optional libraries below the lowest tested version may still work, but are not c
300335
+=================+=================+=========+
301336
| beautifulsoup4 | 4.6.0 | |
302337
+-----------------+-----------------+---------+
303-
| fastparquet | 0.3.2 | |
338+
| fastparquet | 0.4.0 | X |
304339
+-----------------+-----------------+---------+
305340
| fsspec | 0.7.4 | |
306341
+-----------------+-----------------+---------+
@@ -372,8 +407,9 @@ Deprecations
372407
- Deprecated :meth:`core.window.ewm.ExponentialMovingWindow.vol` (:issue:`39220`)
373408
- Using ``.astype`` to convert between ``datetime64[ns]`` dtype and :class:`DatetimeTZDtype` is deprecated and will raise in a future version, use ``obj.tz_localize`` or ``obj.dt.tz_localize`` instead (:issue:`38622`)
374409
- Deprecated casting ``datetime.date`` objects to ``datetime64`` when used as ``fill_value`` in :meth:`DataFrame.unstack`, :meth:`DataFrame.shift`, :meth:`Series.shift`, and :meth:`DataFrame.reindex`, pass ``pd.Timestamp(dateobj)`` instead (:issue:`39767`)
375-
- Deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` in favour of :meth:`.Styler.format` with ``na_rep`` and ``precision`` as existing and new input arguments respectively (:issue:`40134`)
410+
- Deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` in favour of :meth:`.Styler.format` with ``na_rep`` and ``precision`` as existing and new input arguments respectively (:issue:`40134`, :issue:`40425`)
376411
- Deprecated allowing partial failure in :meth:`Series.transform` and :meth:`DataFrame.transform` when ``func`` is list-like or dict-like; will raise if any function fails on a column in a future version (:issue:`40211`)
412+
- Deprecated support for ``np.ma.mrecords.MaskedRecords`` in the :class:`DataFrame` constructor, pass ``{name: data[name] for name in data.dtype.names}`` instead (:issue:`40363`)
377413

378414
.. ---------------------------------------------------------------------------
379415
@@ -460,7 +496,7 @@ Conversion
460496
- Bug in :meth:`Series.view` and :meth:`Index.view` when converting between datetime-like (``datetime64[ns]``, ``datetime64[ns, tz]``, ``timedelta64``, ``period``) dtypes (:issue:`39788`)
461497
- Bug in creating a :class:`DataFrame` from an empty ``np.recarray`` not retaining the original dtypes (:issue:`40121`)
462498
- Bug in :class:`DataFrame` failing to raise ``TypeError`` when constructing from a ``frozenset`` (:issue:`40163`)
463-
-
499+
- Bug in :class:`Index` construction silently ignoring a passed ``dtype`` when the data cannot be cast to that dtype (:issue:`21311`)
464500

465501
Strings
466502
^^^^^^^
@@ -597,6 +633,7 @@ Reshaping
597633
- Bug in :meth:`DataFrame.pivot_table` returning a ``MultiIndex`` for a single value when operating on and empty ``DataFrame`` (:issue:`13483`)
598634
- Allow :class:`Index` to be passed to the :func:`numpy.all` function (:issue:`40180`)
599635
- Bug in :meth:`DataFrame.stack` not preserving ``CategoricalDtype`` in a ``MultiIndex`` (:issue:`36991`)
636+
- Bug in :func:`to_datetime` raising error when input sequence contains unhashable items (:issue:`39756`)
600637

601638
Sparse
602639
^^^^^^
@@ -630,6 +667,7 @@ Other
630667
- Bug in :class:`Styler` where multiple elements in CSS-selectors were not correctly added to ``table_styles`` (:issue:`39942`)
631668
- Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`)
632669
- Bug in :func:`pandas.util.show_versions` where console JSON output was not proper JSON (:issue:`39701`)
670+
- Bug in :meth:`DataFrame.convert_dtypes` incorrectly raised ValueError when called on an empty DataFrame (:issue:`40393`)
633671

634672

635673
.. ---------------------------------------------------------------------------

pandas/_libs/index.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import warnings
22

3+
cimport cython
4+
35
import numpy as np
46

57
cimport numpy as cnp
@@ -47,6 +49,7 @@ cdef inline bint is_definitely_invalid_key(object val):
4749
_SIZE_CUTOFF = 1_000_000
4850

4951

52+
@cython.freelist(32)
5053
cdef class IndexEngine:
5154

5255
cdef readonly:

pandas/_libs/missing.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ cpdef bint checknull(object val):
104104
- np.datetime64 representation of NaT
105105
- np.timedelta64 representation of NaT
106106
- NA
107+
- Decimal("NaN")
107108
108109
Parameters
109110
----------
@@ -143,6 +144,8 @@ cpdef bint checknull_old(object val):
143144
- NaT
144145
- np.datetime64 representation of NaT
145146
- np.timedelta64 representation of NaT
147+
- NA
148+
- Decimal("NaN")
146149
147150
Parameters
148151
----------
@@ -175,6 +178,8 @@ cpdef ndarray[uint8_t] isnaobj(ndarray arr):
175178
- NaT
176179
- np.datetime64 representation of NaT
177180
- np.timedelta64 representation of NaT
181+
- NA
182+
- Decimal("NaN")
178183
179184
Parameters
180185
----------
@@ -211,6 +216,7 @@ def isnaobj_old(arr: ndarray) -> ndarray:
211216
- NEGINF
212217
- NaT
213218
- NA
219+
- Decimal("NaN")
214220

215221
Parameters
216222
----------
@@ -249,6 +255,8 @@ def isnaobj2d(arr: ndarray) -> ndarray:
249255
- NaT
250256
- np.datetime64 representation of NaT
251257
- np.timedelta64 representation of NaT
258+
- NA
259+
- Decimal("NaN")
252260

253261
Parameters
254262
----------
@@ -293,6 +301,8 @@ def isnaobj2d_old(arr: ndarray) -> ndarray:
293301
- NaT
294302
- np.datetime64 representation of NaT
295303
- np.timedelta64 representation of NaT
304+
- NA
305+
- Decimal("NaN")
296306

297307
Parameters
298308
----------

pandas/_libs/parsers.pyx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,10 @@ cdef extern from "parser/tokenizer.h":
284284

285285

286286
cdef extern from "parser/io.h":
287-
void *new_mmap(char *fname)
288-
int del_mmap(void *src)
289-
void* buffer_mmap_bytes(void *source, size_t nbytes,
290-
size_t *bytes_read, int *status)
291-
292-
void *new_file_source(char *fname, size_t buffer_size) except NULL
293-
294287
void *new_rd_source(object obj) except NULL
295288

296-
int del_file_source(void *src)
297289
int del_rd_source(void *src)
298290

299-
void* buffer_file_bytes(void *source, size_t nbytes,
300-
size_t *bytes_read, int *status)
301-
302291
void* buffer_rd_bytes(void *source, size_t nbytes,
303292
size_t *bytes_read, int *status, const char *encoding_errors)
304293

0 commit comments

Comments
 (0)