-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Thoughts on DataFrame index not being columns, grouping issues #3275
Comments
At the end of the day, the purpose of indexes is:
That the index can be assigned to / replaced is also a feature. However, it can also be a nuisance when you're using a DataFrame like an SQL table-- e.g. append(..)-ing DataFrames or things of that nature. It's a tough call. The dual use of DataFrame as an in-memory database table and a "collection of labeled arrays" has made it hard to be all things to all people. The former use case came later, which is why things aren't quite perfectly designed for the database-type use case. More work to do and probably room for a slightly different table object in pandas. |
I agree with the spirit of the argument, that there could be more consistency in the API Index/Multindex does support C is tricky. edit: #3275 merged into master ( In [133]: df=mkdf(5,2,r_idx_nlevels=2)
In [134]: df
Out[134]:
C0 C_l0_g0 C_l0_g1
R0 R1
R_l0_g0 R_l1_g0 R0C0 R0C1
R_l0_g1 R_l1_g1 R1C0 R1C1
R_l0_g2 R_l1_g2 R2C0 R2C1
R_l0_g3 R_l1_g3 R3C0 R3C1
R_l0_g4 R_l1_g4 R4C0 R4C1
In [13]: # so now this is possible
In [135]: df[df.index.to_series().map(lambda x: "l0_g2" in x[0])]
Out[135]:
C0 C_l0_g0 C_l0_g1
R0 R1
R_l0_g2 R_l1_g2 R2C0 R2C1 |
+1 I often find myself getting into the underlying array of tuples because of these issues. |
I have trouble for merges, and my solution so far is a very wasteful one: to keep a named index as well as a column copy of it. Things would much improve for merges if upon a KeyError in resolving a column name, the index names would be used before finally giving up. It seems that this would greatly enhance the relational usability of Pandas. Would this have any unwanted side-effects? |
Didn't catch that. code example? |
Ok, that was insufficient because I did not explain the scenario: I keep track of the foreign keys for each table and have an automated merge mechanism based on column names. When going for merges, the asymmetry between the |
Closing due to age and request ambiguity |
from mailing list
The text was updated successfully, but these errors were encountered: