Indexing and Selecting Data with Pandas

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

22 Terms

1
New cards
Selecting a Single Column
first = data["Age"]
2
New cards
Selecting Multiple Columns
first = data[["Age", "College", "Salary"]]
3
New cards
Selecting a Single Row by Label
row = data.loc["Avery Bradley"]
4
New cards
Selecting Multiple Rows
rows = data.loc[["Avery Bradley", "R.J. Hunter"]]
5
New cards
Selecting Specific Rows and Columns
selection = data.loc[["Avery Bradley", "R.J. Hunter"], ["Team", "]Number", "Position"]
6
New cards
Selecting All Rows and Specific Columns
all_rows_specific_columns = data.loc[:, ["Team", "Position", "Salary"]]
7
New cards
Selecting a Single Row by Position
row = data.iloc[3]
8
New cards
Selecting Multiple Rows by Position
rows = data.iloc[[3, 5, 7]]
9
New cards
Selecting Specific Rows and Columns by Position
selection = data.iloc[[3, 4], [1, 2]]
10
New cards
Selecting All Rows and Specific Columns by Position
selection = data.iloc[:, [1, 2]]
11
New cards
.head(): Returns the first n rows of a DataFrame
print(data.head(5))
12
New cards
.tail(): Returns the last n rows of a DataFrame
print(data.tail(5))
13
New cards
.at[]: Access a single value for a row/column label pair
value = data.at["Avery Bradley", "Age"]
14
New cards
.query(): Query the DataFrame using a boolean expression
result = data.query("Age > 25 and College == 'Duke'")
15
New cards
DataFrame.iat[]
Access a single value for a row/column pair by integer position.
16
New cards
DataFrame.pop()
Return item and drop from DataFrame.
17
New cards
DataFrame.xs()
Return a cross-section (row(s) or column(s)) from the DataFrame.
18
New cards
DataFrame.get()
Get item from object for given key (e.g DataFrame column).
19
New cards
DataFrame.isin()
Return a boolean DataFrame showing whether each element is contained in values.
20
New cards
DataFrame.where()
Return an object of the same shape with entries from self where cond is True otherwise from other.
21
New cards
DataFrame.mask()
Return an object of the same shape with entries from self where cond is False otherwise from other.
22
New cards
DataFrame.insert()
Insert a column into DataFrame at a specified location.