Introduction To Data Science Using Python Part2
Introduction To Data Science Using Python Part2
Typing the name of any variable at the end of a code cell will display the contents of
the variable.
Reading in Data From Excel
So, what is df_grades and how does it store the data?
Jupyter notebook
Reading in Data From Excel
• If the data is really large you don’t want to print out the entire dataframe to your
output.
• The head(n) method outputs the first n rows of the data frame. If n is not supplied,
the default is the first 5 rows.
• I like to run the head() method after I read in the dataframe to check that everything
got read in correctly.
• There is also a tail(n) method that returns the last n rows of the dataframe
Basic Features
Think of this
as a list
object = string
float64 = decimal
int64 = integer
Basic Features
column names
• Pandas defaults to have the index be the row number and it will automatically
recognize that the first row is the column names.
Slice/index through
the index, which is
usually numbers
Slicing a Series
Slice/index through
the index, which is
usually numbers
Slice/index through
the index, which is
usually numbers
Slice/index through
the index, which is
usually numbers
• There are a few ways to pick slice a data frame, we will use the .loc method.
first_row is a series
Slicing a Data Frame
I can actually get all key stats for numeric columns at once with the describe()
method:
summary_df is
a dataframe!
Built in Functions
I can actually get all key stats for numeric columns at once with the describe()
method:
Built in Functions
I can actually get all key stats for numeric columns at once with the describe()
method:
value_count(): Gives a count of the number of times each unique value apears in the
column. Returns a series where indices are the unique column values.
Built in Functions
value_count(): Gives a count of the number of times each unique value appears in the
column. Returns a series where indices are the unique column values.
Built in Functions
dataframe attributes
dataframe methods
Attributes vs. Methods
dataframe attributes
dataframe methods
Features of dataframe
Creating New Columns
We can also create column as function of other column. The Final was worth 36
points, let’s create a column for each student’s percentage.
Deleting Columns
Deleting Columns