@@ -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
613613commands 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+
615663Backwards Compatibility
616664~~~~~~~~~~~~~~~~~~~~~~~
617665
@@ -1078,6 +1126,8 @@ or a new keyword argument (`example <https://github.com/pandas-dev/pandas/blob/v
10781126Contributing your changes to *pandas *
10791127=====================================
10801128
1129+ .. _contributing.commit-code :
1130+
10811131Committing 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+
11251177Pushing your changes
11261178--------------------
11271179
0 commit comments