@@ -612,6 +612,54 @@ Alternatively, you can install the ``grep`` and ``xargs`` commands via the
612
612
`MinGW <http://www.mingw.org/ >`__ toolchain, and it will allow you to run the
613
613
commands above.
614
614
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
+
615
663
Backwards Compatibility
616
664
~~~~~~~~~~~~~~~~~~~~~~~
617
665
@@ -1078,6 +1126,8 @@ or a new keyword argument (`example <https://github.com/pandas-dev/pandas/blob/v
1078
1126
Contributing your changes to *pandas *
1079
1127
=====================================
1080
1128
1129
+ .. _contributing.commit-code :
1130
+
1081
1131
Committing your code
1082
1132
--------------------
1083
1133
@@ -1122,6 +1172,8 @@ Now you can commit your changes in your local repository::
1122
1172
1123
1173
git commit -m
1124
1174
1175
+ .. _contributing.push-code :
1176
+
1125
1177
Pushing your changes
1126
1178
--------------------
1127
1179
0 commit comments