Skip to content

Commit d97cc48

Browse files
author
dcreekp
committed
Merge branch 'master' into validate_docstrings-add-ignore_known_fail-argument
2 parents a7472d3 + aa9574d commit d97cc48

File tree

88 files changed

+1397
-1545
lines changed

Some content is hidden

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

88 files changed

+1397
-1545
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
<td>Package Status</td>
2727
<td>
2828
<a href="https://pypi.org/project/pandas/">
29-
<img src="https://img.shields.io/pypi/status/pandas.svg" alt="status" /></td>
29+
<img src="https://img.shields.io/pypi/status/pandas.svg" alt="status" />
3030
</a>
31+
</td>
3132
</tr>
3233
<tr>
3334
<td>License</td>
@@ -73,8 +74,8 @@
7374
<td>Gitter</td>
7475
<td>
7576
<a href="https://gitter.im/pydata/pandas">
76-
<img src="https://badges.gitter.im/Join%20Chat.svg"
77-
</a>
77+
<img src="https://badges.gitter.im/Join%20Chat.svg" />
78+
</a>
7879
</td>
7980
</tr>
8081
</table>

ci/code_checks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ fi
241241
### DOCSTRINGS ###
242242
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
243243

244-
MSG='Validate docstrings (GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG
245-
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05
244+
MSG='Validate docstrings (GL03, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG
245+
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05
246246
RET=$(($RET + $?)) ; echo $MSG "DONE"
247247

248248
fi

doc/source/getting_started/10min.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Display the index, columns:
103103
df.columns
104104
105105
:meth:`DataFrame.to_numpy` gives a NumPy representation of the underlying data.
106-
Note that his can be an expensive operation when your :class:`DataFrame` has
106+
Note that this can be an expensive operation when your :class:`DataFrame` has
107107
columns with different data types, which comes down to a fundamental difference
108108
between pandas and NumPy: **NumPy arrays have one dtype for the entire array,
109109
while pandas DataFrames have one dtype per column**. When you call

doc/source/getting_started/dsintro.rst

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ To write code compatible with all versions of Python, split the assignment in tw
576576
577577
.. warning::
578578

579-
Dependent assignment maybe subtly change the behavior of your code between
579+
Dependent assignment may subtly change the behavior of your code between
580580
Python 3.6 and older versions of Python.
581581

582-
If you wish write code that supports versions of python before and after 3.6,
582+
If you wish to write code that supports versions of python before and after 3.6,
583583
you'll need to take care when passing ``assign`` expressions that
584584

585-
* Updating an existing column
586-
* Referring to the newly updated column in the same ``assign``
585+
* Update an existing column
586+
* Refer to the newly updated column in the same ``assign``
587587

588588
For example, we'll update column "A" and then refer to it when creating "B".
589589

@@ -665,8 +665,8 @@ row-wise. For example:
665665
666666
df - df.iloc[0]
667667
668-
In the special case of working with time series data, and the DataFrame index
669-
also contains dates, the broadcasting will be column-wise:
668+
In the special case of working with time series data, if the DataFrame index
669+
contains dates, the broadcasting will be column-wise:
670670

671671
.. ipython:: python
672672
:okwarning:
@@ -1030,47 +1030,3 @@ method:
10301030
major_axis=pd.date_range('1/1/2000', periods=5),
10311031
minor_axis=['a', 'b', 'c', 'd'])
10321032
panel.to_frame()
1033-
1034-
1035-
.. _dsintro.deprecate_panel:
1036-
1037-
Deprecate Panel
1038-
---------------
1039-
1040-
Over the last few years, pandas has increased in both breadth and depth, with new features,
1041-
datatype support, and manipulation routines. As a result, supporting efficient indexing and functional
1042-
routines for ``Series``, ``DataFrame`` and ``Panel`` has contributed to an increasingly fragmented and
1043-
difficult-to-understand code base.
1044-
1045-
The 3-D structure of a ``Panel`` is much less common for many types of data analysis,
1046-
than the 1-D of the ``Series`` or the 2-D of the ``DataFrame``. Going forward it makes sense for
1047-
pandas to focus on these areas exclusively.
1048-
1049-
Oftentimes, one can simply use a MultiIndex ``DataFrame`` for easily working with higher dimensional data.
1050-
1051-
In addition, the ``xarray`` package was built from the ground up, specifically in order to
1052-
support the multi-dimensional analysis that is one of ``Panel`` s main use cases.
1053-
`Here is a link to the xarray panel-transition documentation <https://xarray.pydata.org/en/stable/pandas.html#panel-transition>`__.
1054-
1055-
.. ipython:: python
1056-
:okwarning:
1057-
1058-
import pandas.util.testing as tm
1059-
p = tm.makePanel()
1060-
p
1061-
1062-
Convert to a MultiIndex DataFrame.
1063-
1064-
.. ipython:: python
1065-
:okwarning:
1066-
1067-
p.to_frame()
1068-
1069-
Alternatively, one can convert to an xarray ``DataArray``.
1070-
1071-
.. ipython:: python
1072-
:okwarning:
1073-
1074-
p.to_xarray()
1075-
1076-
You can see the full-documentation for the `xarray package <https://xarray.pydata.org/en/stable/>`__.

doc/source/user_guide/indexing.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Selection By Position
435435
This is sometimes called ``chained assignment`` and should be avoided.
436436
See :ref:`Returning a View versus Copy <indexing.view_versus_copy>`.
437437

438-
Pandas provides a suite of methods in order to get **purely integer based indexing**. The semantics follow closely Python and NumPy slicing. These are ``0-based`` indexing. When slicing, the start bounds is *included*, while the upper bound is *excluded*. Trying to use a non-integer, even a **valid** label will raise an ``IndexError``.
438+
Pandas provides a suite of methods in order to get **purely integer based indexing**. The semantics follow closely Python and NumPy slicing. These are ``0-based`` indexing. When slicing, the start bound is *included*, while the upper bound is *excluded*. Trying to use a non-integer, even a **valid** label will raise an ``IndexError``.
439439

440440
The ``.iloc`` attribute is the primary access method. The following are valid inputs:
441441

@@ -545,7 +545,7 @@ Selection By Callable
545545
.. versionadded:: 0.18.1
546546

547547
``.loc``, ``.iloc``, and also ``[]`` indexing can accept a ``callable`` as indexer.
548-
The ``callable`` must be a function with one argument (the calling Series, DataFrame or Panel) and that returns valid output for indexing.
548+
The ``callable`` must be a function with one argument (the calling Series, DataFrame or Panel) that returns valid output for indexing.
549549

550550
.. ipython:: python
551551
@@ -569,7 +569,7 @@ You can use callable indexing in ``Series``.
569569
df1.A.loc[lambda s: s > 0]
570570
571571
Using these methods / indexers, you can chain data selection operations
572-
without using temporary variable.
572+
without using a temporary variable.
573573

574574
.. ipython:: python
575575
@@ -907,7 +907,7 @@ of the DataFrame):
907907
908908
df[df['A'] > 0]
909909
910-
List comprehensions and ``map`` method of Series can also be used to produce
910+
List comprehensions and the ``map`` method of Series can also be used to produce
911911
more complex criteria:
912912

913913
.. ipython:: python
@@ -1556,7 +1556,7 @@ See :ref:`Advanced Indexing <advanced>` for usage of MultiIndexes.
15561556
ind
15571557
15581558
``set_names``, ``set_levels``, and ``set_codes`` also take an optional
1559-
`level`` argument
1559+
``level`` argument
15601560

15611561
.. ipython:: python
15621562

doc/source/user_guide/io.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ The ``Series`` and ``DataFrame`` objects have an instance method ``to_csv`` whic
16891689
allows storing the contents of the object as a comma-separated-values file. The
16901690
function takes a number of arguments. Only the first is required.
16911691

1692-
* ``path_or_buf``: A string path to the file to write or a StringIO
1692+
* ``path_or_buf``: A string path to the file to write or a file object. If a file object it must be opened with `newline=''`
16931693
* ``sep`` : Field delimiter for the output file (default ",")
16941694
* ``na_rep``: A string representation of a missing value (default '')
16951695
* ``float_format``: Format string for floating point numbers
@@ -1702,7 +1702,7 @@ function takes a number of arguments. Only the first is required.
17021702
* ``mode`` : Python write mode, default 'w'
17031703
* ``encoding``: a string representing the encoding to use if the contents are
17041704
non-ASCII, for Python versions prior to 3
1705-
* ``line_terminator``: Character sequence denoting line end (default '\\n')
1705+
* ``line_terminator``: Character sequence denoting line end (default `os.linesep`)
17061706
* ``quoting``: Set quoting rules as in csv module (default csv.QUOTE_MINIMAL). Note that if you have set a `float_format` then floats are converted to strings and csv.QUOTE_NONNUMERIC will treat them as non-numeric
17071707
* ``quotechar``: Character used to quote fields (default '"')
17081708
* ``doublequote``: Control quoting of ``quotechar`` in fields (default True)

doc/source/whatsnew/v0.13.1.rst

Lines changed: 122 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,60 +222,155 @@ Enhancements
222222
223223
- Panel :meth:`~pandas.Panel.apply` will work on non-ufuncs. See :ref:`the docs<basics.apply>`.
224224

225-
.. ipython:: python
225+
.. code-block:: ipython
226+
227+
In [28]: import pandas.util.testing as tm
228+
229+
In [29]: panel = tm.makePanel(5)
226230
227-
import pandas.util.testing as tm
228-
panel = tm.makePanel(5)
229-
panel
230-
panel['ItemA']
231+
In [30]: panel
232+
Out[30]:
233+
<class 'pandas.core.panel.Panel'>
234+
Dimensions: 3 (items) x 5 (major_axis) x 4 (minor_axis)
235+
Items axis: ItemA to ItemC
236+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
237+
Minor_axis axis: A to D
238+
239+
In [31]: panel['ItemA']
240+
Out[31]:
241+
A B C D
242+
2000-01-03 -0.673690 0.577046 -1.344312 -1.469388
243+
2000-01-04 0.113648 -1.715002 0.844885 0.357021
244+
2000-01-05 -1.478427 -1.039268 1.075770 -0.674600
245+
2000-01-06 0.524988 -0.370647 -0.109050 -1.776904
246+
2000-01-07 0.404705 -1.157892 1.643563 -0.968914
247+
248+
[5 rows x 4 columns]
231249
232250
Specifying an ``apply`` that operates on a Series (to return a single element)
233251

234-
.. ipython:: python
252+
.. code-block:: ipython
253+
254+
In [32]: panel.apply(lambda x: x.dtype, axis='items')
255+
Out[32]:
256+
A B C D
257+
2000-01-03 float64 float64 float64 float64
258+
2000-01-04 float64 float64 float64 float64
259+
2000-01-05 float64 float64 float64 float64
260+
2000-01-06 float64 float64 float64 float64
261+
2000-01-07 float64 float64 float64 float64
235262
236-
panel.apply(lambda x: x.dtype, axis='items')
263+
[5 rows x 4 columns]
237264
238265
A similar reduction type operation
239266

240-
.. ipython:: python
267+
.. code-block:: ipython
268+
269+
In [33]: panel.apply(lambda x: x.sum(), axis='major_axis')
270+
Out[33]:
271+
ItemA ItemB ItemC
272+
A -1.108775 -1.090118 -2.984435
273+
B -3.705764 0.409204 1.866240
274+
C 2.110856 2.960500 -0.974967
275+
D -4.532785 0.303202 -3.685193
241276
242-
panel.apply(lambda x: x.sum(), axis='major_axis')
277+
[4 rows x 3 columns]
243278
244279
This is equivalent to
245280

246-
.. ipython:: python
281+
.. code-block:: ipython
282+
283+
In [34]: panel.sum('major_axis')
284+
Out[34]:
285+
ItemA ItemB ItemC
286+
A -1.108775 -1.090118 -2.984435
287+
B -3.705764 0.409204 1.866240
288+
C 2.110856 2.960500 -0.974967
289+
D -4.532785 0.303202 -3.685193
247290
248-
panel.sum('major_axis')
291+
[4 rows x 3 columns]
249292
250293
A transformation operation that returns a Panel, but is computing
251294
the z-score across the major_axis
252295

253-
.. ipython:: python
296+
.. code-block:: ipython
254297
255-
result = panel.apply(lambda x: (x - x.mean()) / x.std(),
256-
axis='major_axis')
257-
result
258-
result['ItemA']
298+
In [35]: result = panel.apply(lambda x: (x - x.mean()) / x.std(),
299+
....: axis='major_axis')
300+
....:
301+
302+
In [36]: result
303+
Out[36]:
304+
<class 'pandas.core.panel.Panel'>
305+
Dimensions: 3 (items) x 5 (major_axis) x 4 (minor_axis)
306+
Items axis: ItemA to ItemC
307+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
308+
Minor_axis axis: A to D
309+
310+
In [37]: result['ItemA'] # noqa E999
311+
Out[37]:
312+
A B C D
313+
2000-01-03 -0.535778 1.500802 -1.506416 -0.681456
314+
2000-01-04 0.397628 -1.108752 0.360481 1.529895
315+
2000-01-05 -1.489811 -0.339412 0.557374 0.280845
316+
2000-01-06 0.885279 0.421830 -0.453013 -1.053785
317+
2000-01-07 0.742682 -0.474468 1.041575 -0.075499
318+
319+
[5 rows x 4 columns]
259320
260321
- Panel :meth:`~pandas.Panel.apply` operating on cross-sectional slabs. (:issue:`1148`)
261322

262-
.. ipython:: python
323+
.. code-block:: ipython
263324
264-
def f(x):
265-
return ((x.T - x.mean(1)) / x.std(1)).T
325+
In [38]: def f(x):
326+
....: return ((x.T - x.mean(1)) / x.std(1)).T
327+
....:
266328
267-
result = panel.apply(f, axis=['items', 'major_axis'])
268-
result
269-
result.loc[:, :, 'ItemA']
329+
In [39]: result = panel.apply(f, axis=['items', 'major_axis'])
270330
271-
This is equivalent to the following
331+
In [40]: result
332+
Out[40]:
333+
<class 'pandas.core.panel.Panel'>
334+
Dimensions: 4 (items) x 5 (major_axis) x 3 (minor_axis)
335+
Items axis: A to D
336+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
337+
Minor_axis axis: ItemA to ItemC
272338
273-
.. ipython:: python
339+
In [41]: result.loc[:, :, 'ItemA']
340+
Out[41]:
341+
A B C D
342+
2000-01-03 0.012922 -0.030874 -0.629546 -0.757034
343+
2000-01-04 0.392053 -1.071665 0.163228 0.548188
344+
2000-01-05 -1.093650 -0.640898 0.385734 -1.154310
345+
2000-01-06 1.005446 -1.154593 -0.595615 -0.809185
346+
2000-01-07 0.783051 -0.198053 0.919339 -1.052721
347+
348+
[5 rows x 4 columns]
274349
275-
result = pd.Panel({ax: f(panel.loc[:, :, ax]) for ax in panel.minor_axis})
350+
This is equivalent to the following
351+
352+
.. code-block:: ipython
276353
277-
result
278-
result.loc[:, :, 'ItemA']
354+
In [42]: result = pd.Panel({ax: f(panel.loc[:, :, ax]) for ax in panel.minor_axis})
355+
356+
In [43]: result
357+
Out[43]:
358+
<class 'pandas.core.panel.Panel'>
359+
Dimensions: 4 (items) x 5 (major_axis) x 3 (minor_axis)
360+
Items axis: A to D
361+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
362+
Minor_axis axis: ItemA to ItemC
363+
364+
In [44]: result.loc[:, :, 'ItemA']
365+
Out[44]:
366+
A B C D
367+
2000-01-03 0.012922 -0.030874 -0.629546 -0.757034
368+
2000-01-04 0.392053 -1.071665 0.163228 0.548188
369+
2000-01-05 -1.093650 -0.640898 0.385734 -1.154310
370+
2000-01-06 1.005446 -1.154593 -0.595615 -0.809185
371+
2000-01-07 0.783051 -0.198053 0.919339 -1.052721
372+
373+
[5 rows x 4 columns]
279374
280375
Performance
281376
~~~~~~~~~~~

0 commit comments

Comments
 (0)