Skip to content

Commit 5494313

Browse files
committed
Merge remote-tracking branch 'upstream/master' into unpin-numpydev
2 parents 7ddef8e + 0bb24b7 commit 5494313

Some content is hidden

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

64 files changed

+1203
-483
lines changed

ci/code_checks.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
4444
flake8 pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
4545
RET=$(($RET + $?)) ; echo $MSG "DONE"
4646

47+
# Check that cython casting is of the form `<type>obj` as opposed to `<type> obj`;
48+
# it doesn't make a difference, but we want to be internally consistent.
49+
# Note: this grep pattern is (intended to be) equivalent to the python
50+
# regex r'(?<![ ->])> '
51+
MSG='Linting .pyx code for spacing conventions in casting' ; echo $MSG
52+
! grep -r -E --include '*.pyx' --include '*.pxi.in' '> ' pandas/_libs | grep -v '[ ->]> '
53+
RET=$(($RET + $?)) ; echo $MSG "DONE"
54+
4755
# readability/casting: Warnings about C casting instead of C++ casting
4856
# runtime/int: Warnings about using C number types instead of C++ ones
4957
# build/include_subdir: Warnings about prefacing included header files with directory
@@ -123,7 +131,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
123131

124132
MSG='Doctests frame.py' ; echo $MSG
125133
pytest -q --doctest-modules pandas/core/frame.py \
126-
-k"-axes -combine -itertuples -join -nlargest -nsmallest -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack -to_stata"
134+
-k"-axes -combine -itertuples -join -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack -to_stata"
127135
RET=$(($RET + $?)) ; echo $MSG "DONE"
128136

129137
MSG='Doctests series.py' ; echo $MSG

doc/source/basics.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ We encourage you to view the source code of :meth:`~DataFrame.pipe`.
767767

768768
.. _dplyr: https://github.com/hadley/dplyr
769769
.. _magrittr: https://github.com/smbache/magrittr
770-
.. _R: http://www.r-project.org
770+
.. _R: https://www.r-project.org
771771

772772

773773
Row or Column-wise Function Application
@@ -2296,7 +2296,7 @@ For example, to select ``bool`` columns:
22962296
df.select_dtypes(include=[bool])
22972297
22982298
You can also pass the name of a dtype in the `NumPy dtype hierarchy
2299-
<http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html>`__:
2299+
<https://docs.scipy.org/doc/numpy/reference/arrays.scalars.html>`__:
23002300

23012301
.. ipython:: python
23022302

doc/source/comparison_with_sas.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ Length
365365
~~~~~~
366366

367367
SAS determines the length of a character string with the
368-
`LENGTHN <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002284668.htm>`__
369-
and `LENGTHC <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002283942.htm>`__
368+
`LENGTHN <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002284668.htm>`__
369+
and `LENGTHC <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002283942.htm>`__
370370
functions. ``LENGTHN`` excludes trailing blanks and ``LENGTHC`` includes trailing blanks.
371371

372372
.. code-block:: sas
@@ -391,7 +391,7 @@ Find
391391
~~~~
392392

393393
SAS determines the position of a character in a string with the
394-
`FINDW <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002978282.htm>`__ function.
394+
`FINDW <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002978282.htm>`__ function.
395395
``FINDW`` takes the string defined by the first argument and searches for the first position of the substring
396396
you supply as the second argument.
397397

@@ -417,7 +417,7 @@ Substring
417417
~~~~~~~~~
418418

419419
SAS extracts a substring from a string based on its position with the
420-
`SUBSTR <http://www2.sas.com/proceedings/sugi25/25/cc/25p088.pdf>`__ function.
420+
`SUBSTR <https://www2.sas.com/proceedings/sugi25/25/cc/25p088.pdf>`__ function.
421421

422422
.. code-block:: sas
423423
@@ -438,7 +438,7 @@ indexes are zero-based.
438438
Scan
439439
~~~~
440440

441-
The SAS `SCAN <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm>`__
441+
The SAS `SCAN <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm>`__
442442
function returns the nth word from a string. The first argument is the string you want to parse and the
443443
second argument specifies which word you want to extract.
444444

@@ -469,9 +469,9 @@ approaches, but this just shows a simple approach.
469469
Upcase, Lowcase, and Propcase
470470
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
471471

472-
The SAS `UPCASE <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245965.htm>`__
473-
`LOWCASE <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245912.htm>`__ and
474-
`PROPCASE <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a002598106.htm>`__
472+
The SAS `UPCASE <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245965.htm>`__
473+
`LOWCASE <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245912.htm>`__ and
474+
`PROPCASE <https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a002598106.htm>`__
475475
functions change the case of the argument.
476476

477477
.. code-block:: sas
@@ -709,7 +709,7 @@ This means that the size of data able to be loaded in pandas is limited by your
709709
machine's memory, but also that the operations on that data may be faster.
710710

711711
If out of core processing is needed, one possibility is the
712-
`dask.dataframe <http://dask.pydata.org/en/latest/dataframe.html>`_
712+
`dask.dataframe <https://dask.pydata.org/en/latest/dataframe.html>`_
713713
library (currently in development) which
714714
provides a subset of pandas functionality for an on-disk ``DataFrame``
715715

doc/source/comparison_with_sql.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Comparison with SQL
55
********************
66
Since many potential pandas users have some familiarity with
7-
`SQL <http://en.wikipedia.org/wiki/SQL>`_, this page is meant to provide some examples of how
7+
`SQL <https://en.wikipedia.org/wiki/SQL>`_, this page is meant to provide some examples of how
88
various SQL operations would be performed using pandas.
99

1010
If you're new to pandas, you might want to first read through :ref:`10 Minutes to pandas<10min>`
@@ -59,7 +59,7 @@ Filtering in SQL is done via a WHERE clause.
5959
LIMIT 5;
6060
6161
DataFrames can be filtered in multiple ways; the most intuitive of which is using
62-
`boolean indexing <http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing>`_.
62+
`boolean indexing <https://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing>`_.
6363

6464
.. ipython:: python
6565

doc/source/conf.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
# JP: added from sphinxdocs
100100
autosummary_generate = False
101101

102-
if any(re.match("\s*api\s*", l) for l in index_rst_lines):
102+
if any(re.match(r"\s*api\s*", l) for l in index_rst_lines):
103103
autosummary_generate = True
104104

105105
# numpydoc
@@ -341,8 +341,8 @@
341341
# file, target name, title, author, documentclass [howto/manual]).
342342
latex_documents = [
343343
('index', 'pandas.tex',
344-
u'pandas: powerful Python data analysis toolkit',
345-
u'Wes McKinney\n\& PyData Development Team', 'manual'),
344+
'pandas: powerful Python data analysis toolkit',
345+
r'Wes McKinney\n\& PyData Development Team', 'manual'),
346346
]
347347

348348
# The name of an image file (relative to this directory) to place at the top of
@@ -569,7 +569,11 @@ def linkcode_resolve(domain, info):
569569
return None
570570

571571
try:
572-
fn = inspect.getsourcefile(obj)
572+
# inspect.unwrap() was added in Python version 3.4
573+
if sys.version_info >= (3, 5):
574+
fn = inspect.getsourcefile(inspect.unwrap(obj))
575+
else:
576+
fn = inspect.getsourcefile(obj)
573577
except:
574578
fn = None
575579
if not fn:

doc/source/contributing.rst

+52
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,54 @@ Alternatively, you can install the ``grep`` and ``xargs`` commands via the
612612
`MinGW <http://www.mingw.org/>`__ toolchain, and it will allow you to run the
613613
commands above.
614614

615+
.. _contributing.import-formatting:
616+
617+
Import Formatting
618+
~~~~~~~~~~~~~~~~~
619+
*pandas* uses `isort <https://pypi.org/project/isort/>`__ to standardise import
620+
formatting across the codebase.
621+
622+
A guide to import layout as per pep8 can be found `here <https://www.python.org/dev/peps/pep-0008/#imports/>`__.
623+
624+
A summary of our current import sections ( in order ):
625+
626+
* Future
627+
* Python Standard Library
628+
* Third Party
629+
* ``pandas._libs``, ``pandas.compat``, ``pandas.util._*``, ``pandas.errors`` (largely not dependent on ``pandas.core``)
630+
* ``pandas.core.dtypes`` (largely not dependent on the rest of ``pandas.core``)
631+
* Rest of ``pandas.core.*``
632+
* Non-core ``pandas.io``, ``pandas.plotting``, ``pandas.tseries``
633+
* Local application/library specific imports
634+
635+
Imports are alphabetically sorted within these sections.
636+
637+
638+
As part of :ref:`Continuous Integration <contributing.ci>` checks we run::
639+
640+
isort --recursive --check-only pandas
641+
642+
to check that imports are correctly formatted as per the `setup.cfg`.
643+
644+
If you see output like the below in :ref:`Continuous Integration <contributing.ci>` checks:
645+
646+
.. code-block:: shell
647+
648+
Check import format using isort
649+
ERROR: /home/travis/build/pandas-dev/pandas/pandas/io/pytables.py Imports are incorrectly sorted
650+
Check import format using isort DONE
651+
The command "ci/code_checks.sh" exited with 1
652+
653+
You should run::
654+
655+
isort pandas/io/pytables.py
656+
657+
to automatically format imports correctly. This will modify your local copy of the files.
658+
659+
The `--recursive` flag can be passed to sort all files in a directory.
660+
661+
You can then verify the changes look ok, then git :ref:`commit <contributing.commit-code>` and :ref:`push <contributing.push-code>`.
662+
615663
Backwards Compatibility
616664
~~~~~~~~~~~~~~~~~~~~~~~
617665

@@ -1078,6 +1126,8 @@ or a new keyword argument (`example <https://github.com/pandas-dev/pandas/blob/v
10781126
Contributing your changes to *pandas*
10791127
=====================================
10801128

1129+
.. _contributing.commit-code:
1130+
10811131
Committing your code
10821132
--------------------
10831133

@@ -1122,6 +1172,8 @@ Now you can commit your changes in your local repository::
11221172

11231173
git commit -m
11241174

1175+
.. _contributing.push-code:
1176+
11251177
Pushing your changes
11261178
--------------------
11271179

doc/source/contributing_docstring.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function or method, so programmers can understand what it does without having
1616
to read the details of the implementation.
1717

1818
Also, it is a common practice to generate online (html) documentation
19-
automatically from docstrings. `Sphinx <http://www.sphinx-doc.org>`_ serves
19+
automatically from docstrings. `Sphinx <https://www.sphinx-doc.org>`_ serves
2020
this purpose.
2121

2222
Next example gives an idea on how a docstring looks like:
@@ -68,7 +68,7 @@ As PEP-257 is quite open, and some other standards exist on top of it. In the
6868
case of pandas, the numpy docstring convention is followed. The conventions is
6969
explained in this document:
7070

71-
* `numpydoc docstring guide <http://numpydoc.readthedocs.io/en/latest/format.html>`_
71+
* `numpydoc docstring guide <https://numpydoc.readthedocs.io/en/latest/format.html>`_
7272
(which is based in the original `Guide to NumPy/SciPy documentation
7373
<https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_)
7474

@@ -78,7 +78,7 @@ The standard uses reStructuredText (reST). reStructuredText is a markup
7878
language that allows encoding styles in plain text files. Documentation
7979
about reStructuredText can be found in:
8080

81-
* `Sphinx reStructuredText primer <http://www.sphinx-doc.org/en/stable/rest.html>`_
81+
* `Sphinx reStructuredText primer <https://www.sphinx-doc.org/en/stable/rest.html>`_
8282
* `Quick reStructuredText reference <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
8383
* `Full reStructuredText specification <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html>`_
8484

@@ -119,7 +119,7 @@ backticks. It is considered inline code:
119119
function, prefix it with ``~``. For example, ``:class:`~pandas.Series```
120120
will link to ``pandas.Series`` but only display the last part, ``Series``
121121
as the link text. See `Sphinx cross-referencing syntax
122-
<http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-syntax>`_
122+
<https://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-syntax>`_
123123
for details.
124124

125125
**Good:**

0 commit comments

Comments
 (0)