-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: show users how to emulate R c function with iloc slicing and r_ #6499
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
DOC: show users how to emulate R c function with iloc slicing and r_ #6499
Conversation
Nice comparison! |
@jorisvandenbossche Thanks! I'll add that. |
columns = named + np.arange(len(named), 100).tolist() | ||
df = DataFrame(np.random.randn(100, 100), columns=columns) | ||
|
||
df.iloc[:, c(r_[:10], r_[24:30], 39, r_[49:100])] |
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.
Actually, I think you can just do: df.iloc[:, r_[:10, 24:30, 39, 49:100]]
?
Another alternative (without the somewhat strange r_
function) is the very basic usage of range (but somewhat longer):
df.iloc[:, range(10) + range(24, 30), range(49, 100)]
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.
@jorisvandenbossche Awesome. I didn't know that.
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.
I also just discovered it now :-) So certainly check if it is the same.
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.
It is, just checked it. Here's the SO question that inspired this addition to the docs.
@jorisvandenbossche Any more comments? |
Nope, thanks! Maybe just check tomorrow the rendered dev doc to see if everything looks good |
DOC: show users how to emulate R c function with iloc slicing and r_
FYI the docs builds almost immediately after it's merged |
No description provided.