Learn programming in Pandas, a Python Library, 100 seconds at a time in this video for beginners. This is video number 3: Basic data anlysis on a csv data source
00:12 - CSV file
00:24 - Loading csv file in Jupyter Notebook
00:34 - value_counts() function
01:00 - mean function
01:10 - describe function on a column
01:22 - sort function
—————————————————————
Hands on with Pandas CSV
—————————————————————
Note this video will use methods covered in the previous tutorial and has a fast pace
Screen record list with thumbnail previous video
In the previous video we covered the pandas dataframe
Get the dataframe slide from keynote previous video
In this video we will use the dataframe on an excel file and answer some questions about the data
Add an excel file icon to previous slide
We will use fictional employee data made available via towerwatson. Link to the file is in the description
Go to website with link, use kaggle and open excel file
The excel file looks something like this.
Exelfile should already be open and go over columns
We have columns with data such as employee number, gender, age, etc.
Lets import pandas, read the excel file and create a data frame like this.
df = pd.read_csv('/Users/username/Downloads/WA_Fn-UseC_-HR-Employee-Attrition.csv', index_col='EmployeeNumber')
Let’s quickly take a look at the data using the head function to check if the dataframe works.
neat.
df.head()
The value_count function is used to count how often a value occurs. We can use another column as an index. Here’s an example
Lets say we want to know how many employees there are per department. The values are the amount of employees and we will use the department as an index
df['Department'].value_counts()
This function can also be used to tell us what rate of a certain value.
So if we want to know the split between male/female we need to pass the keyword-argument or name-value pair with the name normalize and set the value as true
df['Gender'].value_counts(normalize=True)
The mean fucntion helps with returning the average value. If we want to know the average years an employee spends in this company, we can apply the method like this
df['YearsAtCompany'].mean()
We’ve seen the describe function before, when we applied to the whole dataframe.
But the describe method can also be applied to a single column.
This is handy if you’re doing exploratory data analysis and need to know more about a column
df['YearsAtCompany'].describe()
Finally the sort method can be used to rearrange a column ascending or descending
This is particularly handy if you need to find the lowest or highest value
df['Age'].sort_values(ascending=True)
df['Age'].sort_values(ascending=False)[:3]
Keep an eye out for the next video where we will continue using pandas
————————————————————————
🦁 Who are you?
My name is Raza. I am 30. I am an IT - manager right now, but I’ve been an accountant for the majority of my career.
I’m in love with #Python :)
You can find me here:
📷 Instagram: / razacodes
📈 Twitter: / razacodes
—————————————————————————————
Goals for 2021
Training Python hours: 70/1000
Python/Django Projects: 2/30
Subscribers: 4130/10,000
—————————————————————————————-
#100SecondsOfCode
#pythonforbeginners #programming
On this page of the site you can watch the video online Python Pandas Tutorial for Absolute Beginners - #3 Basic Data Analysis on a CSV with a duration of hours minute second in good quality, which was uploaded by the user Raza Zaidi 03 April 2021, share the link with friends and acquaintances, this video has already been watched 458 times on youtube and it was liked by 20 viewers. Enjoy your viewing!