Python Pandas1 Intro and Series Flashcards
What do you have to do before you install the Pandas library?
You have to install NumPy; Pandas is built upon NumPy.
What other computing platform is Pandas similar to?
R
What new data object types does Pandas introduce?
Series and DataFrames
What is the difference between an array and a series?
An array is indexed by integers, but a series can be indexed by labels.
How do you create a Series?
you can use the pd.series() function to transform a list, array or dictionary into a Series.
What is a DataFrame
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 do you extract a column of data?
Like this df[‘W’] or you can pretend df is a SQL table, and do df.W
How do you extract a row of data?
Use df.loc[‘A’] to get row A. You can also use its 0-based row index, df.iloc[0]
How to get a single value
Get row B, column Y like this: df.loc[‘B’,’Y’]
How to get a sub-matrix-type thingy?
df.loc[[‘A’,’B’],[‘W’,’Y’]]