Skip to content

Conversation

@cpcloud
Copy link
Member

@cpcloud cpcloud commented Feb 27, 2014

No description provided.

@cpcloud cpcloud added the Docs label Feb 27, 2014
@cpcloud cpcloud self-assigned this Feb 27, 2014
@jorisvandenbossche
Copy link
Member

Nice comparison!
Just a remark, you didn't really give the pandas alternative for your first case (to access columns by name), so maybe add that? (df[, c("a", "c", "e")] -> df[["a", "c", "e"]])

@cpcloud
Copy link
Member Author

cpcloud commented Feb 27, 2014

@jorisvandenbossche Thanks! I'll add that.

Copy link
Member

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)]

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@cpcloud
Copy link
Member Author

cpcloud commented Feb 27, 2014

@jorisvandenbossche Any more comments?

@jorisvandenbossche
Copy link
Member

Nope, thanks! Maybe just check tomorrow the rendered dev doc to see if everything looks good

jorisvandenbossche added a commit that referenced this pull request Feb 27, 2014
DOC: show users how to emulate R c function with iloc slicing and r_
@jorisvandenbossche jorisvandenbossche merged commit f94a8d5 into pandas-dev:master Feb 27, 2014
@cpcloud cpcloud deleted the r-slicing-with-c branch February 27, 2014 22:30
@jreback
Copy link
Contributor

jreback commented Feb 27, 2014

FYI the docs builds almost immediately after it's merged

http://pandas-docs.github.io/pandas-docs-travis/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants