Skip to content

Commit 012a635

Browse files
authored
Merge pull request #146 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 2ba9ad3 + 7af47c9 commit 012a635

Some content is hidden

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

48 files changed

+460
-728
lines changed

.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]

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Optional libraries below the lowest tested version may still work, but are not c
300300
+=================+=================+=========+
301301
| beautifulsoup4 | 4.6.0 | |
302302
+-----------------+-----------------+---------+
303-
| fastparquet | 0.3.2 | |
303+
| fastparquet | 0.4.0 | X |
304304
+-----------------+-----------------+---------+
305305
| fsspec | 0.7.4 | |
306306
+-----------------+-----------------+---------+
@@ -367,8 +367,9 @@ Deprecations
367367
- Deprecated :meth:`core.window.ewm.ExponentialMovingWindow.vol` (:issue:`39220`)
368368
- 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`)
369369
- 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`)
370-
- 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`)
370+
- 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`)
371371
- 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`)
372+
- 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`)
372373

373374
.. ---------------------------------------------------------------------------
374375
@@ -455,7 +456,7 @@ Conversion
455456
- Bug in :meth:`Series.view` and :meth:`Index.view` when converting between datetime-like (``datetime64[ns]``, ``datetime64[ns, tz]``, ``timedelta64``, ``period``) dtypes (:issue:`39788`)
456457
- Bug in creating a :class:`DataFrame` from an empty ``np.recarray`` not retaining the original dtypes (:issue:`40121`)
457458
- Bug in :class:`DataFrame` failing to raise ``TypeError`` when constructing from a ``frozenset`` (:issue:`40163`)
458-
-
459+
- Bug in :class:`Index` construction silently ignoring a passed ``dtype`` when the data cannot be cast to that dtype (:issue:`21311`)
459460

460461
Strings
461462
^^^^^^^
@@ -592,6 +593,7 @@ Reshaping
592593
- Bug in :meth:`DataFrame.pivot_table` returning a ``MultiIndex`` for a single value when operating on and empty ``DataFrame`` (:issue:`13483`)
593594
- Allow :class:`Index` to be passed to the :func:`numpy.all` function (:issue:`40180`)
594595
- Bug in :meth:`DataFrame.stack` not preserving ``CategoricalDtype`` in a ``MultiIndex`` (:issue:`36991`)
596+
- Bug in :func:`to_datetime` raising error when input sequence contains unhashable items (:issue:`39756`)
595597

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

629632

630633
.. ---------------------------------------------------------------------------

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

pandas/_libs/src/parser/io.c

Lines changed: 0 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -9,83 +9,10 @@ The full license is in the LICENSE file, distributed with this software.
99

1010
#include "io.h"
1111

12-
#include <sys/stat.h>
13-
#include <fcntl.h>
14-
15-
#ifndef O_BINARY
16-
#define O_BINARY 0
17-
#endif // O_BINARY
18-
19-
#ifdef _WIN32
20-
#define USE_WIN_UTF16
21-
#include <Windows.h>
22-
#endif
23-
2412
/*
2513
On-disk FILE, uncompressed
2614
*/
2715

28-
void *new_file_source(char *fname, size_t buffer_size) {
29-
file_source *fs = (file_source *)malloc(sizeof(file_source));
30-
if (fs == NULL) {
31-
PyErr_NoMemory();
32-
return NULL;
33-
}
34-
35-
#ifdef USE_WIN_UTF16
36-
// Fix gh-15086 properly - convert UTF8 to UTF16 that Windows widechar API
37-
// accepts. This is needed because UTF8 might _not_ be convertible to MBCS
38-
// for some conditions, as MBCS is locale-dependent, and not all unicode
39-
// symbols can be expressed in it.
40-
{
41-
wchar_t* wname = NULL;
42-
int required = MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0);
43-
if (required == 0) {
44-
free(fs);
45-
PyErr_SetFromWindowsErr(0);
46-
return NULL;
47-
}
48-
wname = (wchar_t*)malloc(required * sizeof(wchar_t));
49-
if (wname == NULL) {
50-
free(fs);
51-
PyErr_NoMemory();
52-
return NULL;
53-
}
54-
if (MultiByteToWideChar(CP_UTF8, 0, fname, -1, wname, required) <
55-
required) {
56-
free(wname);
57-
free(fs);
58-
PyErr_SetFromWindowsErr(0);
59-
return NULL;
60-
}
61-
fs->fd = _wopen(wname, O_RDONLY | O_BINARY);
62-
free(wname);
63-
}
64-
#else
65-
fs->fd = open(fname, O_RDONLY | O_BINARY);
66-
#endif
67-
if (fs->fd == -1) {
68-
free(fs);
69-
PyErr_SetFromErrnoWithFilename(PyExc_OSError, fname);
70-
return NULL;
71-
}
72-
73-
// Only allocate this heap memory if we are not memory-mapping the file
74-
fs->buffer = (char *)malloc((buffer_size + 1) * sizeof(char));
75-
76-
if (fs->buffer == NULL) {
77-
close(fs->fd);
78-
free(fs);
79-
PyErr_NoMemory();
80-
return NULL;
81-
}
82-
83-
memset(fs->buffer, '\0', buffer_size + 1);
84-
fs->size = buffer_size;
85-
86-
return (void *)fs;
87-
}
88-
8916
void *new_rd_source(PyObject *obj) {
9017
rd_source *rds = (rd_source *)malloc(sizeof(rd_source));
9118

@@ -108,17 +35,6 @@ void *new_rd_source(PyObject *obj) {
10835
10936
*/
11037

111-
int del_file_source(void *ptr) {
112-
file_source *fs = ptr;
113-
if (fs == NULL) return 0;
114-
115-
free(fs->buffer);
116-
close(fs->fd);
117-
free(fs);
118-
119-
return 0;
120-
}
121-
12238
int del_rd_source(void *rds) {
12339
Py_XDECREF(RDS(rds)->obj);
12440
Py_XDECREF(RDS(rds)->buffer);
@@ -133,35 +49,6 @@ int del_rd_source(void *rds) {
13349
13450
*/
13551

136-
void *buffer_file_bytes(void *source, size_t nbytes, size_t *bytes_read,
137-
int *status) {
138-
file_source *fs = FS(source);
139-
ssize_t rv;
140-
141-
if (nbytes > fs->size) {
142-
nbytes = fs->size;
143-
}
144-
145-
rv = read(fs->fd, fs->buffer, nbytes);
146-
switch (rv) {
147-
case -1:
148-
*status = CALLING_READ_FAILED;
149-
*bytes_read = 0;
150-
return NULL;
151-
case 0:
152-
*status = REACHED_EOF;
153-
*bytes_read = 0;
154-
return NULL;
155-
default:
156-
*status = 0;
157-
*bytes_read = rv;
158-
fs->buffer[rv] = '\0';
159-
break;
160-
}
161-
162-
return (void *)fs->buffer;
163-
}
164-
16552
void *buffer_rd_bytes(void *source, size_t nbytes, size_t *bytes_read,
16653
int *status, const char *encoding_errors) {
16754
PyGILState_STATE state;
@@ -218,98 +105,3 @@ void *buffer_rd_bytes(void *source, size_t nbytes, size_t *bytes_read,
218105

219106
return retval;
220107
}
221-
222-
#ifdef HAVE_MMAP
223-
224-
#include <sys/mman.h>
225-
226-
void *new_mmap(char *fname) {
227-
memory_map *mm;
228-
struct stat stat;
229-
size_t filesize;
230-
231-
mm = (memory_map *)malloc(sizeof(memory_map));
232-
if (mm == NULL) {
233-
return NULL;
234-
}
235-
mm->fd = open(fname, O_RDONLY | O_BINARY);
236-
if (mm->fd == -1) {
237-
free(mm);
238-
return NULL;
239-
}
240-
241-
if (fstat(mm->fd, &stat) == -1) {
242-
close(mm->fd);
243-
free(mm);
244-
return NULL;
245-
}
246-
filesize = stat.st_size; /* XXX This might be 32 bits. */
247-
248-
mm->memmap = mmap(NULL, filesize, PROT_READ, MAP_SHARED, mm->fd, 0);
249-
if (mm->memmap == MAP_FAILED) {
250-
close(mm->fd);
251-
free(mm);
252-
return NULL;
253-
}
254-
255-
mm->size = (off_t)filesize;
256-
mm->position = 0;
257-
258-
return mm;
259-
}
260-
261-
int del_mmap(void *ptr) {
262-
memory_map *mm = ptr;
263-
264-
if (mm == NULL) return 0;
265-
266-
munmap(mm->memmap, mm->size);
267-
close(mm->fd);
268-
free(mm);
269-
270-
return 0;
271-
}
272-
273-
void *buffer_mmap_bytes(void *source, size_t nbytes, size_t *bytes_read,
274-
int *status) {
275-
void *retval;
276-
memory_map *src = source;
277-
size_t remaining = src->size - src->position;
278-
279-
if (remaining == 0) {
280-
*bytes_read = 0;
281-
*status = REACHED_EOF;
282-
return NULL;
283-
}
284-
285-
if (nbytes > remaining) {
286-
nbytes = remaining;
287-
}
288-
289-
retval = src->memmap + src->position;
290-
291-
/* advance position in mmap data structure */
292-
src->position += nbytes;
293-
294-
*bytes_read = nbytes;
295-
*status = 0;
296-
297-
return retval;
298-
}
299-
300-
#else
301-
302-
/* kludgy */
303-
304-
void *new_mmap(char *fname) { return NULL; }
305-
306-
int del_mmap(void *src) { return 0; }
307-
308-
/* don't use this! */
309-
310-
void *buffer_mmap_bytes(void *source, size_t nbytes, size_t *bytes_read,
311-
int *status) {
312-
return NULL;
313-
}
314-
315-
#endif // HAVE_MMAP

0 commit comments

Comments
 (0)