Pd Basics Flashcards
How to read a CSV using pandas?
Pd.read_csv(‘link’)
How to get the NUM of rows and columns?
Df.shape
How to get more specified information about the data frame for example index type
Df.info()
How to display the list of columns?
Df.columns
How to set a limit of columns to 85?
Pd.set_option(‘display.max_columns’,85)
How to print first 3 values?
Df.head(3)
How to print last 3 values?
Df.tail(3)
What is a data frame?
Data frame is a two dimensional array with additional functions
What is a series?
Series is a one dimensional array with additional functions
How would you print the first 3 elements using iloc where you want to return only column 2 as output
Df.iloc[[0,1,2],2] or df.iloc[0:3,2]
What’s the difference between loc and iloc
Iloc uses indices as columns loc uses their actual names
What does Inplace=True do?
Applies the change to the data frame
How would you change the index of a column with a different one?
Df.set_index(‘column’)
How would you reset the indices?
Df.reset_index()
How would you sort the indices?
Df.sort_index()
What is a filter mask? Give one example
A filter mask is a Boolean expression, if a row is True compared to this expression, it will be displayed. Filt = (df[‘cost’] == 0)
What do these signs mean: & |~
And or not
How to check if a series contains a certain value?
Df[column].isin()