-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
KeyError for crosstab on Series with same name. #6319
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
Comments
I am not sure this is a bug, what would you expect this to do? |
I can't remember if the previous versions added to the column labels or just dropped them. It would look something like either:
or
|
I'm having the exact same issue manifested in a slightly different way. In my case, I'm using With a simple dataframe like this
When we pivot
which makes perfect sense. Similarly, I would expect that if I pivoted
|
@johnhess for your problem you can workaround with something like
It looks like these are cause by the same issue: how ipdb> agged
__dummy__
s s
1 1 3
2 3 3 I don't think that @jreback any objection to having checks in |
@TomAugspurger that sounds reasonable. maybe a ValueError or something with an explanation. In theory could have a |
@TomAugspurger Thanks for taking the time to look into it! I have another workaround in at the moment, so I'm safe, but I worry that others will expect pandas to crosstab any two valid series and end up with surprise errors. In my case, users of my application have an interface to crosstab any two columns and I hadn't realized I needed a special case when they have the same name. |
👍 to a better error message, imo better to raise than infer here. |
@hayd I addressed the error msg in #6738 I agree that However, there in the cases of |
is might make sense in pivot to collapse the index (just droplevel(1)) |
@TomAugspurger for 0.14? or since you fixed the error can bump? |
I'm not seeing a quick fix here. The current pivot_table implementation depends on not having any repeats in |
can you raise a NotImplementedError for this part? |
this appears fixed. if someone could locate the reference we can close. |
Closed by #16028 |
This is not fixed for me, using pandas.version 0.23.1:
still raises an error for me. Edit: Submitted as issue #21765 |
Could you open a new issue with that example and all your version info?
…On Fri, Jul 6, 2018 at 6:27 AM, kasuteru ***@***.***> wrote:
This is not fixed for me, using pandas.*version* 0.23.1:
print(pd.__version__)
df = pd.DataFrame(data={"a":[1,2,3,4]})
a1 = df["a"]
a2 = df["a"]
pd.crosstab(a1,a2)
still raises an error for me.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6319 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIhYgHzArkEo384cxWymDsJoqvglwks5uD0mFgaJpZM4BgwcP>
.
|
I submitted it as #21765. Turns out that the example provided here also fails, so I used that. |
Doing a crosstab on two Series with the same name throws an error. This is due to a dictionary (indexed by the series name) in the crosstab function being used to store the data. Not sure if this is a feature or a bug, but a default similar to the behavior when Series without name are compared would be desirable to me.
The text was updated successfully, but these errors were encountered: