-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
CLN deprecate save&load in favour of to_pickle&read_pickle #3787
Conversation
though you were going to move to io/pickle.py ? I guess not much code.... need to add in io.rst / v0.11.1 the to_pickle/from_pickle refs.... also...the pickling section in the docs, I think in basics.rst should be moved to io.rst |
I haven't managed to do that yet (getting some nasty circular import errors...) I will move the pickle docs to io anyway. |
you can leave save/load where they are (but import to_pickle/from_pickle from io/pickle) I think will fix |
I'm pretty sure I tried that exactly, but it wasn't working. Will stash apply and push it here so we can have a look. |
@jreback something obvious? |
@@ -25,6 +20,8 @@ | |||
|
|||
from pandas.core.config import get_option | |||
from pandas.core import array as pa | |||
import pandas.io.pickle as pkl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the problem, do this IN the save routine (and load routine), so you don't get circular inputs (e.g. to_hdf in core/generic.py)
Darn, this means I can't do my clever @set_doc thing... (Thanks it was indeed that!) |
ok, updated (Still WIP). Should I rename the method Related, while messing around... odd behaviour with the type checking of
|
didn't realized there was a |
as to your |
Nono, there isn't. I was going to call it
There's no * well, 4. |
maybe I misundestaood....
in 0.12...also fixing the inheritance so that things like |
Yeah that's where it is in the pr :), just giving example. Currently |
where is |
|
|
||
@classmethod #@set_doc(pkl.read_pickle) | ||
def read_pickle(cls, path): | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need this (its already in core.common)
so take both read_pickle and load out of generic? I think that's reasonable. Ruthless, but reasonable... :) |
yes....read_xxx ONLY operate from the top level (which makes sense because you a) don't want to have to add to every conceivable object, and b) you could have different return objects based on your options (e.g. the squeeze option in pd.read_csv) the so (and the idea was to completely presever back compat with the old names (but provide warnings) then break on 0.12 |
as an aside.....there is a pandas.utils.decorators '@deprecate'...but of course I didn't use it anywhere..... you want to change the warnings to use this? (i think also io.parsers.ExcelFile would need changing too) |
Ok, your inline comments have confused me. Just to confirm:
last two are already current behaviour of pr. If that's right, I also should remove references to Series.read_pickle and friends from the api rsts. (yeah I'll go through the warnings.) |
save/load are screwed up......so
end up with 1 save, 1 load (in the right places, just deprecated) also remove |
I didn't realize save/load were in so many places.....bad code :) |
|
That comes from numpy... hmmm even if we delete load in pandas does this mean it'll still be there? |
I don't think that is actually necessary |
i can't wait for msgpack...! |
yep....if some is insterest in another project....I think that pandas needs to incorporate the msgpack cython code directly (I think the license is ok) to make it more efficient |
I'll wait to merge. This is going to make some people grumpy but easy to fix their code. Btw guys, I will pull msgpack directly into pandas for customization... |
@hayd andy this is easy to make completely back compat; just import load/save into top-level name space from com (and then have those versions show the warnings), then call the appropriate to / from pickle....so just like with other io API, providing warning if you use the original method in 0.11.1, but still works, removing in 0.12 (in favor or new method) |
So keep all instances of save and load (but with deprecate warning), basically back to our earlier iteration (?) but to_pickle not in top level... |
yes on save/load to_pickle is an instance method, and also a top-level method (so should be in io.api AND core/generic) |
Really? I thought we were killing that and just going to have read_pickle top level (and save and load)? to_pickle (and save and load) instance methods. |
yes (I am reversing myself).....I guess save/load exist as imports from top-level and com now, so let's leave all those cases (with a warning) for now (also load on instance methods? ) then fix all in 0.12 |
How it's working:
I still have to fiddle around with the docs a little (I've probably missed some things), and then will squash. |
that looks good I am +1 on merging (when you r done with docs) @wesm ? |
@jreback As we discussed, save and load have remained in common, but I'm not sure how to do the main api.rst when functions are across two (core.common and io.pickle)... should I just drop save and load from the api.rst? |
yes I would they r deprecated |
Ok, I think that's it, have rebased and squashed. I don't think I've missed any save/load calls anywhere (tests/travis seem happy). |
@wesm ok to merge on this, should provide complete back-compat (with a warning), and introduce new conformat to_pickle / read_pickle syntax |
okay merge away. By the way, going to have to leave in the deprecated |
Will delete bits saying "and will be removed in v0.12" then :) That is an excellent idea. |
ok pls let me know when ready to merge |
DOC replace save&load with to_pickle&read_pickle
Ready! |
CLN deprecate save&load in favour of to_pickle&read_pickle
Does it make sense to add support for reading from file like objects (StringIO) and writing to such objects to |
Add
read_pickle
to top-level andto_pickle
as instance methods, deprecation warning til 0.12 for save and load everwhere. See lower down for how it's working.Both
read_pickle
andto_pickle
are inio.pickle
, save&load remain incore.common
(but call to_pickle, read_pickle resp).cc #3782.