Skip to content

CLN: reorg pandas/io/json to sub-dirs #15322

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

Closed
wants to merge 2 commits into from
Closed

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Feb 6, 2017

xref #14904

@jreback jreback added Clean IO JSON read_json, to_json, json_normalize labels Feb 6, 2017
@jreback jreback added this to the 0.20.0 milestone Feb 6, 2017
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super!

I would only call json.py -> _json.py and normalize.py -> _normalize.py so it is very explicit only the things in __init__.py are regarded as public

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

@jorisvandenbossche done, waiting for build to finish and will merge.

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

actually I changed it back; you can simply delete the module names and they don't appear in the namespace. I don't like having private _ leading modules in a sub-dir. I think its a bit messy.

@jorisvandenbossche
Copy link
Member

you can simply delete the module names and they don't appear in the namespace

The disadvantage of this is that they are still in the namespace, you just can't tab complete them, but still import (I think). I agree that the leading _ is a bit ugly, but IMO that is a clean way to keep the internal organisation of the module internal (of course you can still import it, but at least it gives you a signal that you shouldn't do it), and have all public functions in __init__.py

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

The disadvantage of this is that they are still in the namespace, you just can't tab complete them, but

In [1]: from pandas.io import json

In [2]: dir(json)
Out[2]: 
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'dumps',
 'json_normalize',
 'loads',
 'read_json',
 'to_json']

In [3]: json.json
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-79fda60ed4a6> in <module>()
----> 1 json.json

AttributeError: module 'pandas.io.json' has no attribute 'json'

you can do from pandas.io.json import json but so what.

this removes most/all of the stuff from the namespace.

@jorisvandenbossche
Copy link
Member

Hmm, I am getting some strange errors with ipython tab completion with this branch.

First, on from pandas.io.json import TAB, they still are visible, and on from pandas.io.json.normalize import TAB, I get an AttributeError, after which tab completion completely stops working, also for other things. So ipython does not seem to play very well with del (although I also though that should work)

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

I think you have to delete the .pyc! they are NOT automatically deleted, when you move things around the old ones are still there.

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

@jorisvandenbossche py2 is crazy! (nvm was a flake issue)

https://travis-ci.org/jreback/pandas/jobs/199007258

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

@jorisvandenbossche
Copy link
Member

Still giving me the same troubles with ipython completion after deleting the pyc files (and even after a full setup.py clean and rebuild)

So I would either just remove the del, or use the _ in the file names.

you can do from pandas.io.json import json but so what.

It's not that important, but in my experience, people tend to see that pd.io.json.json_normalize returns pandas.io.json.normalize.json_normalize in the terminal, and then use that path to use it later.

@jreback jreback closed this in 34cdfa4 Feb 6, 2017
@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

@jorisvandenbossche just merged. try it again.

@jreback
Copy link
Contributor Author

jreback commented Feb 6, 2017

we don't use _ leading anywhere else, except to mean compiled code. So pretty loath to resort to that.

@jorisvandenbossche
Copy link
Member

You cannot replicate the problem I see? (eg on from pandas.io.json.json.TAB) I am still having the same problem with master.

we don't use _ leading anywhere

Yes, but changing habits always starts somewhere :-) And you typically do it there were you reorganize files and have the chance to do it. I also wanted to propose it for the new plotting module. But anyway, we don't have to decide it here and now.
But, if the ipython completion problems are not due to something on my computer, I would at least remove the del

@TomAugspurger
Copy link
Contributor

@jorisvandenbossche what version of IPython are you using? I don't see any issues with IPython master.

Ahh, but installing IPython 5.2.2, I do see the tab completer crashing :/

AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
xref pandas-dev#14904

Author: Jeff Reback <[email protected]>

Closes pandas-dev#15322 from jreback/json and squashes the following commits:

0c2da60 [Jeff Reback] DOC: whatsnew update
fa3deef [Jeff Reback] CLN: reorg pandas/io/json to sub-dirs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants