-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Feature request: df that only return dfs when indexing. #3237
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
are you looking for something like this? (this is 0.11-dev)
|
And if you ALWAYS want to force a df to return (the above is ALWAYS a scalar)
|
.get_value() does not seem to support multi-indices x.get_value([0,1], 'a'). However, x.loc seems to do exactly what I need. Thanks! |
@twiecki great! yes, by definition while |
I tried this again just now but df.loc[0,:] returns a series again. Was this changed by any chance? This is with current master. |
You asked for a Series, this will always return a series, enclose the list of rows with a and FYI, the
|
Perfect. Thanks! |
With more complex dataframes, I often stumble over this:
This is just an example, at other times I end up converting the
Series
back to aDataFrame
because that's what the rest of the code expects.I know that there have been attempts to solve this issue by adding attribute lookup to
Series
(e.g. #1904) but they seem to come with a performance penalty.Often, however, I care more about expressiveness than performance. I thus propose the addition of an option like:
Which will cause x.ix[0] or x.a to return again a
DataFrame
rather than aSeries
and make the above work. The default would be False so that there are no backward compat issues. Alternatively there could be a new DataFrame class that inherits from DataFrame and has the desired behavior.I'm happy to gives this a crack, however, I wanted to first make sure that it's not only me who thinks that'd be a good idea or that this can't work for obvious reason X.
The text was updated successfully, but these errors were encountered: