Skip to main content
Rollback to Revision 8
Source Link
user2285236
user2285236

gets the same columns asis equivalent to

df[['C', 'D', 'E']] # Mind, this makes# aor copy.

or

df.loc[:, ['C', 'D', 'E']] # This does not make a copy (better).

gets the same columns as

df[['C', 'D', 'E']] # Mind, this makes a copy.

or

df.loc[:, ['C', 'D', 'E']] # This does not make a copy (better).

is equivalent to

df[['C', 'D', 'E']]  # or df.loc[:, ['C', 'D', 'E']]
added the comments in the answer, since a full copy should be avoided and not just be said in some comment
Source Link
questionto42
  • 10k
  • 8
  • 82
  • 127

is equivalent togets the same columns as

df[['C', 'D', 'E']]  # orMind, this makes a copy.

or

df.loc[:, ['C', 'D', 'E']] # This does not make a copy (better).

is equivalent to

df[['C', 'D', 'E']]  # or df.loc[:, ['C', 'D', 'E']]

gets the same columns as

df[['C', 'D', 'E']] # Mind, this makes a copy.

or

df.loc[:, ['C', 'D', 'E']] # This does not make a copy (better).
added 4 characters in body
Source Link
Anoushiravan R
  • 22.1k
  • 3
  • 22
  • 44

To get the columns from CC to E E (note that unlike integer slicing, 'E'E is included in the columns):

The same works for selecting rows based on labels. Get the rows 'R6'R6 to 'R10'R10 from those columns:

To get the columns from C to E (note that unlike integer slicing, 'E' is included in the columns):

The same works for selecting rows based on labels. Get the rows 'R6' to 'R10' from those columns:

To get the columns from C to E (note that unlike integer slicing, E is included in the columns):

The same works for selecting rows based on labels. Get the rows R6 to R10 from those columns:

Active reading [<https://en.wiktionary.org/wiki/Boolean#Noun>].
Source Link
Peter Mortensen
  • 31.1k
  • 22
  • 111
  • 134
Loading
added 8 characters in body
Source Link
user2285236
user2285236
Loading
added 84 characters in body
Source Link
user2285236
user2285236
Loading
added 108 characters in body
Source Link
user2285236
user2285236
Loading
added 38 characters in body
Source Link
user2285236
user2285236
Loading
added 10 characters in body
Source Link
user2285236
user2285236
Loading
Source Link
user2285236
user2285236
Loading