-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: consistent imports ('import pandas as pd' et al) #9886
Comments
@jreback @shoyer @TomAugspurger @sinhrks What do you think about this? |
I think we agree here.
|
agree with @shoyer here. I would prob show should show esp in 10min to pandas. Not really concerned about in the docs itself, but I guess it could be a bit unclear. Are you proposing prefixing all calls with
|
@shoyer On question 3: yes indeed, apart from @jreback Yes, indeed: |
I think that might be a bit too far. I would be +1 on this for 10min to pandas. But IMHO just clutters the docs otherwise. and we don't do it ANYWHERE IIRC. |
In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: import matplotlib.pyplot as plt at the start of the 10 minute intro. I think that's ok. All others should imported (and shown to be imported), say once per section? We shouldn't assume people are reading the docs straight through. So I think I'm agreeing with @jorisvandenbossche and @shoyer here. |
+1 for @shoyer and @TomAugspurger . And I prefer |
@jreback That's the reason I brought it up, as now we don't do this, although recommend it. But I think we should be consistent in the first place. If we recommend it, we should do it ourselves. If we do it in 10min, we should do it in all the docs, although this is more verbose. |
For question 4, anybody a preference out of those two?
|
I started with some files, see #9987 (long train rit today :-)), so that is what it would look like if I follow the above. |
BUG: 10633 - some last errors removed ENH: pickle support for Period pandas-dev#10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue pandas-dev#10828 TST: pandas-dev#10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes pandas-dev#10564 DOC: typo A few changes in docs TST: Changes in test ENH: pickle support for Period pandas-dev#10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue pandas-dev#10828 TST: pandas-dev#10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes pandas-dev#10564 DOC: typo ENH: pickle support for Period pandas-dev#10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue pandas-dev#10828 TST: pandas-dev#10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes pandas-dev#10564 DOC: typo A few changes in docs ERR: 10720 BUG: 10633 and 10800 fix merging ENH: pickle support for Period pandas-dev#10439 update legacy_storage for pickles update pickles/msgpack for 0.16.2 Added tests for ABC Types, Issue pandas-dev#10828 TST: pandas-dev#10822, skip tests on windows for odd error message in to_datetime with unicode COMPAT:Allow multi-indexes to be written to excel. (Even though they cannot be read back in.) Closes pandas-dev#10564 DOC: typo A few changes in docs TST: Changes in test Fixing a slight messup DOC:Updating consistent imports in the merging.rst file pandas-dev#9886 DOC: GH9886 Part V DOC: GH9886 Part V - some merging issues
Most is done, overview of the files that still need updates:
|
I'ld like to work on this, for the above files: merging.rst timedeltsd.rst and timeseries.rst |
Looks like the remaining files in #9886 (comment) have consistent import styles now. Going to close out this issue but happy to reopen if we re-catch inconsistent imports in the references. |
Throughout the docs, many different imports are used, not always visible to the reader. And ideally, I think this would be a bit more uniform. I think we need:
So the code snippets can be ran without having to know what should be imported, apart from the default imports.
But in that case, of course, we have to decide/agree on which imports to use.
I think
import pandas as pd
is regarded as recommended? But still, it is not used that much in the docs. So I was wondering, does everybody agree to use that in all docs (and is it just a case of "it is the intention, but no one did it")?So everywhere
pd.DataFrame
andpd.Series
, or do we still want the convenience of usingDataFrame(..)/Series(..)
without thepd
(so to onlyfrom pandas import DataFrame, Series
, and usepd.
for all the rest)?So: Question 1: do we use
import pandas as pd
for everything or not?Then we have the often used imports from other packages. I think this is standard, and should not need discussion:
But for the datetime package, the imports are not really uniform. The following two imports are both used mixed in the docs, but are not compatible with each other:
So: Question 2: How do we import datetime?
Further, there are some other imports used a lot, like
from numpy.random import randn
orfrom numpy import nan
.For other non-pandas imports, I propose that they should always use the standard import (eg
np
) or be done explicitely where used, and never hidden (as it is now the case sometimes, egfrom dateutil.relativedelta import relativedelta
)So: Question 3: Do we agree that all other non-pandas imports should be done explicitely?
This means that imports in the suppressed code block like the following will be removed:
Third issue: there are also some pandas imports of non top-level things.
For pandas submodules, imports like this appear in the docs:
happen in the docs (and often not visible to the users), what I think is a bad idea. First, a lot of these imports should never been done as the functions used from there are also in the top-level pandas namespace.
If it is for functions that are used from the submodules, that we have to decide how to import them. At least, the imports should happen explicitely in the visible docs. But to do that, there are some different forms possible:
So: Question 4: How do we import from pandas submodules?
TO DO:
The text was updated successfully, but these errors were encountered: