Skip to content

Commit 1fc9b0f

Browse files
author
Ayowolet
committed
Merge remote-tracking branch 'upstream/master' into Validate-blanks
2 parents 1effaf4 + c94eaee commit 1fc9b0f

File tree

114 files changed

+2614
-8660
lines changed

Some content is hidden

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

114 files changed

+2614
-8660
lines changed

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
193193
set -o pipefail
194194
if [[ "$AZURE" == "true" ]]; then
195195
# we exclude all c/cpp files as the c/cpp files of pandas code base are tested when Linting .c and .h files
196-
! grep -n '--exclude=*.'{svg,c,cpp,html} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
196+
! grep -n '--exclude=*.'{svg,c,cpp,html,js} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
197197
else
198-
! grep -n '--exclude=*.'{svg,c,cpp,html} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
198+
! grep -n '--exclude=*.'{svg,c,cpp,html,js} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
199199
fi
200200
RET=$(($RET + $?)) ; echo $MSG "DONE"
201201
fi

doc/redirects.csv

-2
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ generated/pandas.DataFrame.to_parquet,../reference/api/pandas.DataFrame.to_parqu
503503
generated/pandas.DataFrame.to_period,../reference/api/pandas.DataFrame.to_period
504504
generated/pandas.DataFrame.to_pickle,../reference/api/pandas.DataFrame.to_pickle
505505
generated/pandas.DataFrame.to_records,../reference/api/pandas.DataFrame.to_records
506-
generated/pandas.DataFrame.to_sparse,../reference/api/pandas.DataFrame.to_sparse
507506
generated/pandas.DataFrame.to_sql,../reference/api/pandas.DataFrame.to_sql
508507
generated/pandas.DataFrame.to_stata,../reference/api/pandas.DataFrame.to_stata
509508
generated/pandas.DataFrame.to_string,../reference/api/pandas.DataFrame.to_string
@@ -1432,7 +1431,6 @@ generated/pandas.Series.to_msgpack,../reference/api/pandas.Series.to_msgpack
14321431
generated/pandas.Series.to_numpy,../reference/api/pandas.Series.to_numpy
14331432
generated/pandas.Series.to_period,../reference/api/pandas.Series.to_period
14341433
generated/pandas.Series.to_pickle,../reference/api/pandas.Series.to_pickle
1435-
generated/pandas.Series.to_sparse,../reference/api/pandas.Series.to_sparse
14361434
generated/pandas.Series.to_sql,../reference/api/pandas.Series.to_sql
14371435
generated/pandas.Series.to_string,../reference/api/pandas.Series.to_string
14381436
generated/pandas.Series.to_timestamp,../reference/api/pandas.Series.to_timestamp

doc/source/reference/frame.rst

-8
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,7 @@ Serialization / IO / conversion
356356
DataFrame.to_msgpack
357357
DataFrame.to_gbq
358358
DataFrame.to_records
359-
DataFrame.to_sparse
360359
DataFrame.to_dense
361360
DataFrame.to_string
362361
DataFrame.to_clipboard
363362
DataFrame.style
364-
365-
Sparse
366-
~~~~~~
367-
.. autosummary::
368-
:toctree: api/
369-
370-
SparseDataFrame.to_coo

doc/source/reference/series.rst

-11
Original file line numberDiff line numberDiff line change
@@ -576,18 +576,7 @@ Serialization / IO / conversion
576576
Series.to_sql
577577
Series.to_msgpack
578578
Series.to_json
579-
Series.to_sparse
580579
Series.to_dense
581580
Series.to_string
582581
Series.to_clipboard
583582
Series.to_latex
584-
585-
586-
Sparse
587-
------
588-
589-
.. autosummary::
590-
:toctree: api/
591-
592-
SparseSeries.to_coo
593-
SparseSeries.from_coo

doc/source/user_guide/io.rst

+8
Original file line numberDiff line numberDiff line change
@@ -4641,6 +4641,14 @@ Several caveats.
46414641

46424642
See the `Full Documentation <https://github.com/wesm/feather>`__.
46434643

4644+
.. ipython:: python
4645+
:suppress:
4646+
4647+
import warnings
4648+
# This can be removed once building with pyarrow >=0.15.0
4649+
warnings.filterwarnings("ignore", "The Sparse", FutureWarning)
4650+
4651+
46444652
.. ipython:: python
46454653
46464654
df = pd.DataFrame({'a': list('abc'),

doc/source/user_guide/sparse.rst

+5-15
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
Sparse data structures
77
**********************
88

9-
.. note::
10-
11-
``SparseSeries`` and ``SparseDataFrame`` have been deprecated. Their purpose
12-
is served equally well by a :class:`Series` or :class:`DataFrame` with
13-
sparse values. See :ref:`sparse.migration` for tips on migrating.
14-
159
Pandas provides data structures for efficiently storing sparse data.
1610
These are not necessarily sparse in the typical "mostly 0". Rather, you can view these
1711
objects as being "compressed" where any data matching a specific value (``NaN`` / missing value, though any value
@@ -168,6 +162,11 @@ the correct dense result.
168162
Migrating
169163
---------
170164

165+
.. note::
166+
167+
``SparseSeries`` and ``SparseDataFrame`` were removed in pandas 1.0.0. This migration
168+
guide is present to aid in migrating from previous versions.
169+
171170
In older versions of pandas, the ``SparseSeries`` and ``SparseDataFrame`` classes (documented below)
172171
were the preferred way to work with sparse data. With the advent of extension arrays, these subclasses
173172
are no longer needed. Their purpose is better served by using a regular Series or DataFrame with
@@ -366,12 +365,3 @@ row and columns coordinates of the matrix. Note that this will consume a signifi
366365
367366
ss_dense = pd.Series.sparse.from_coo(A, dense_index=True)
368367
ss_dense
369-
370-
371-
.. _sparse.subclasses:
372-
373-
Sparse subclasses
374-
-----------------
375-
376-
The :class:`SparseSeries` and :class:`SparseDataFrame` classes are deprecated. Visit their
377-
API pages for usage.

doc/source/whatsnew/v0.16.0.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ Interaction with scipy.sparse
9191

9292
Added :meth:`SparseSeries.to_coo` and :meth:`SparseSeries.from_coo` methods (:issue:`8048`) for converting to and from ``scipy.sparse.coo_matrix`` instances (see :ref:`here <sparse.scipysparse>`). For example, given a SparseSeries with MultiIndex we can convert to a `scipy.sparse.coo_matrix` by specifying the row and column labels as index levels:
9393

94-
.. ipython:: python
95-
:okwarning:
94+
.. code-block:: python
9695
9796
s = pd.Series([3.0, np.nan, 1.0, 3.0, np.nan, np.nan])
9897
s.index = pd.MultiIndex.from_tuples([(1, 2, 'a', 0),
@@ -121,8 +120,7 @@ Added :meth:`SparseSeries.to_coo` and :meth:`SparseSeries.from_coo` methods (:is
121120
The from_coo method is a convenience method for creating a ``SparseSeries``
122121
from a ``scipy.sparse.coo_matrix``:
123122

124-
.. ipython:: python
125-
:okwarning:
123+
.. code-block:: python
126124
127125
from scipy import sparse
128126
A = sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])),

doc/source/whatsnew/v0.18.1.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,7 @@ used in the ``pandas`` implementation (:issue:`12644`, :issue:`12638`, :issue:`1
393393

394394
An example of this signature augmentation is illustrated below:
395395

396-
.. ipython:: python
397-
:okwarning:
396+
.. code-block:: python
398397
399398
sp = pd.SparseDataFrame([1, 2, 3])
400399
sp
@@ -409,8 +408,7 @@ Previous behaviour:
409408
410409
New behaviour:
411410

412-
.. ipython:: python
413-
:okwarning:
411+
.. code-block:: python
414412
415413
np.cumsum(sp, axis=0)
416414

doc/source/whatsnew/v0.19.0.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,7 @@ Operators now preserve dtypes
12351235

12361236
- Sparse data structure now can preserve ``dtype`` after arithmetic ops (:issue:`13848`)
12371237

1238-
.. ipython:: python
1239-
:okwarning:
1238+
.. code-block:: python
12401239
12411240
s = pd.SparseSeries([0, 2, 0, 1], fill_value=0, dtype=np.int64)
12421241
s.dtype
@@ -1245,8 +1244,7 @@ Operators now preserve dtypes
12451244
12461245
- Sparse data structure now support ``astype`` to convert internal ``dtype`` (:issue:`13900`)
12471246

1248-
.. ipython:: python
1249-
:okwarning:
1247+
.. code-block:: python
12501248
12511249
s = pd.SparseSeries([1., 0., 2., 0.], fill_value=0)
12521250
s

doc/source/whatsnew/v0.20.0.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ See the :ref:`documentation <sparse.scipysparse>` for more information. (:issue:
338338

339339
All sparse formats are supported, but matrices that are not in :mod:`COOrdinate <scipy.sparse>` format will be converted, copying data as needed.
340340

341-
.. ipython:: python
342-
:okwarning:
341+
.. code-block:: python
343342
344343
from scipy.sparse import csr_matrix
345344
arr = np.random.random(size=(1000, 5))
@@ -351,7 +350,7 @@ All sparse formats are supported, but matrices that are not in :mod:`COOrdinate
351350
352351
To convert a ``SparseDataFrame`` back to sparse SciPy matrix in COO format, you can use:
353352

354-
.. ipython:: python
353+
.. code-block:: python
355354
356355
sdf.to_coo()
357356

doc/source/whatsnew/v0.25.0.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,7 @@ by a ``Series`` or ``DataFrame`` with sparse values.
902902
903903
**Previous way**
904904
905-
.. ipython:: python
906-
:okwarning:
905+
.. code-block:: python
907906
908907
df = pd.SparseDataFrame({"A": [0, 0, 1, 2]})
909908
df.dtypes

doc/source/whatsnew/v1.0.0.rst

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ Enhancements
2929
Other enhancements
3030
^^^^^^^^^^^^^^^^^^
3131

32+
- :meth:`MultiIndex.from_product` infers level names from inputs if not explicitly provided (:issue:`27292`)
3233
- :meth:`DataFrame.to_latex` now accepts ``caption`` and ``label`` arguments (:issue:`25436`)
3334
- The :ref:`integer dtype <integer_na>` with support for missing values can now be converted to
3435
``pyarrow`` (>= 0.15.0), which means that it is supported in writing to the Parquet file format
3536
when using the ``pyarrow`` engine. It is currently not yet supported when converting back to
3637
pandas (so it will become an integer or float dtype depending on the presence of missing data).
3738
(:issue:`28368`)
38-
-
39+
- :meth:`DataFrame.to_json` now accepts an ``indent`` integer argument to enable pretty printing of JSON output (:issue:`12004`)
3940

4041

4142
Build Changes
@@ -78,7 +79,7 @@ Other API changes
7879
^^^^^^^^^^^^^^^^^
7980

8081
- :meth:`pandas.api.types.infer_dtype` will now return "integer-na" for integer and ``np.nan`` mix (:issue:`27283`)
81-
-
82+
- :meth:`MultiIndex.from_arrays` will no longer infer names from arrays if ``names=None`` is explicitly provided (:issue:`27292`)
8283
-
8384

8485
.. _whatsnew_1000.deprecations:
@@ -91,8 +92,17 @@ Deprecations
9192

9293
.. _whatsnew_1000.prior_deprecations:
9394

95+
96+
Removed SparseSeries and SparseDataFrame
97+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
99+
``SparseSeries`` and ``SparseDataFrame`` have been removed (:issue:`28425`).
100+
We recommend using a ``Series`` or ``DataFrame`` with sparse values instead.
101+
See :ref:`sparse.migration` for help with migrating existing code.
102+
94103
Removal of prior version deprecations/changes
95104
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105+
96106
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
97107
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to False (:issue:`27600`)
98108
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
@@ -122,6 +132,7 @@ Categorical
122132
^^^^^^^^^^^
123133

124134
- Added test to assert the :func:`fillna` raises the correct ValueError message when the value isn't a value from categories (:issue:`13628`)
135+
- Bug in :meth:`Categorical.astype` where ``NaN`` values were handled incorrectly when casting to int (:issue:`28406`)
125136
-
126137
-
127138

@@ -206,6 +217,7 @@ I/O
206217
- Improve infinity parsing. :meth:`read_csv` now interprets ``Infinity``, ``+Infinity``, ``-Infinity`` as floating point values (:issue:`10065`)
207218
- Bug in :meth:`DataFrame.to_csv` where values were truncated when the length of ``na_rep`` was shorter than the text input data. (:issue:`25099`)
208219
- Bug in :func:`DataFrame.to_string` where values were truncated using display options instead of outputting the full content (:issue:`9784`)
220+
- Bug in :meth:`DataFrame.to_json` where a datetime column label would not be written out in ISO format with ``orient="table"`` (:issue:`28130`)
209221

210222
Plotting
211223
^^^^^^^^

environment.yml

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ dependencies:
3636
- nbsphinx
3737
- pandoc
3838

39+
# web (jinja2 is also needed, but it's also an optional pandas dependency)
40+
- markdown
41+
- feedparser
42+
- pyyaml
43+
- requests
44+
3945
# testing
4046
- boto3
4147
- botocore>=1.11

pandas/__init__.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@
114114
DataFrame,
115115
)
116116

117-
from pandas.core.sparse.api import (
118-
SparseArray,
119-
SparseDataFrame,
120-
SparseSeries,
121-
SparseDtype,
122-
)
117+
from pandas.core.sparse.api import SparseArray, SparseDtype
123118

124119
from pandas.tseries.api import infer_freq
125120
from pandas.tseries import offsets
@@ -196,8 +191,9 @@
196191
if pandas.compat.PY37:
197192

198193
def __getattr__(name):
194+
import warnings
195+
199196
if name == "Panel":
200-
import warnings
201197

202198
warnings.warn(
203199
"The Panel class is removed from pandas. Accessing it "
@@ -211,6 +207,17 @@ class Panel:
211207
pass
212208

213209
return Panel
210+
elif name in {"SparseSeries", "SparseDataFrame"}:
211+
warnings.warn(
212+
"The {} class is removed from pandas. Accessing it from "
213+
"the top-level namespace will also be removed in the next "
214+
"version".format(name),
215+
FutureWarning,
216+
stacklevel=2,
217+
)
218+
219+
return type(name, (), {})
220+
214221
raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
215222

216223

@@ -219,6 +226,12 @@ class Panel:
219226
class Panel:
220227
pass
221228

229+
class SparseDataFrame:
230+
pass
231+
232+
class SparseSeries:
233+
pass
234+
222235

223236
# module level doc-string
224237
__doc__ = """

pandas/_libs/src/ujson/lib/ultrajson.h

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ typedef struct __JSONObjectEncoder {
244244
If true, '<', '>', and '&' characters will be encoded as \u003c, \u003e, and \u0026, respectively. If false, no special encoding will be used. */
245245
int encodeHTMLChars;
246246

247+
/*
248+
Configuration for spaces of indent */
249+
int indent;
250+
247251
/*
248252
Set to an error message if error occurred */
249253
const char *errorMsg;

0 commit comments

Comments
 (0)