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
ENH: to_dict(orient="index", into=T) returns T[K, dict], expecting T[K, T] #34109
Comments
I bumped into this while writing act-now-coalition/covid-data-model#394 |
why is this useful at all? |
I used |
Mmm I don't think that's the original behavior of I'm also unsure about adding another parameter to support this since it won't make sense for other orients. |
I had https://docs.python.org/3/library/json.html `object_pairs_hook` in
mind but seems like that isn't the intent with `into`.
…On Mon, May 11, 2020 at 6:57 AM Tom Augspurger ***@***.***> wrote:
Mmm I don't think that's the original behavior of into. I'm hesitant to
overload the meaning of it to apply to nested dictionaries too.
I'm also unsure about adding another parameter to support this since it
won't make sense for other orients.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#34109 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIUBC3L6KLD3BFBKEYUGBDRQ775RANCNFSM4M5M6NNA>
.
|
@TomGoBravo can you share a bit more about your use-case? Right now, I'm leaning towards closing this as out of scope, since I don't want to complicate the signature for orients this doesn't apply to. |
I'm copying a |
I think we need another argument for the inner constructor. In the case where the document states, someone may use the default value defined with My own case is similar to the original post. I want to serialize a data frame as a Lua table used in my fandom wiki. I use luadata which needs a dictionary-like input. As I want to keep the order of recorded and field, I need some way to pass into the constructors of both inner and outer dictionaries. Unfurtuanly, I can not propose a name for the new argument as I think my English is not great enough to do so. |
Code Sample, a copy-pastable example
Live at https://repl.it/@TomGoBravo/RoughUncommonDatabase
Problem description
I expected the
into
parameter to be used for all dicts returned by to_dict but the implementation for orient="index" hasdict
hard-coded. A work around is fairly simple but thought I'd report the issue.Expected Output
I'm expecting the values of the indexed mapping to also be of type
into
, notdict
. The fix is replacingdict
at https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1503 withinto_c
. I tried changing this line of code and re-ran thetest_fast.sh
. It didn't seem to break any tests, I get78277 passed, 8446 skipped, 1000 xfailed, 31 warnings in 967.05s (0:16:07)
vs78277 passed, 8446 skipped, 1000 xfailed, 31 warnings in 1546.42s (0:25:46)
running master with no change.The text was updated successfully, but these errors were encountered: