Python Pandas1 Intro and Series Flashcards

1
Q

What do you have to do before you install the Pandas library?

A

You have to install NumPy; Pandas is built upon NumPy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What other computing platform is Pandas similar to?

A

R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What new data object types does Pandas introduce?

A

Series and DataFrames

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between an array and a series?

A

An array is indexed by integers, but a series can be indexed by labels.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you create a Series?

A

you can use the pd.series() function to transform a list, array or dictionary into a Series.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a DataFrame

A

A bunch of Series that share an index. Each column of numbers is a named series, except the first pseudo column, which is the index values. pd.DataFrame(randn(5,4), [‘A’,’B’,etc],[‘W’,’X’, etc]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you extract a column of data?

A

Like this df[‘W’] or you can pretend df is a SQL table, and do df.W

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you extract a row of data?

A

Use df.loc[‘A’] to get row A. You can also use its 0-based row index, df.iloc[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to get a single value

A

Get row B, column Y like this: df.loc[‘B’,’Y’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to get a sub-matrix-type thingy?

A

df.loc[[‘A’,’B’],[‘W’,’Y’]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly