SlideShare a Scribd company logo
1 of 1
Download to read offline
code in python and explain
Step 1: Import data.
skiprows: This parameter is use to skip passed rows in new data frame
df1 = pd.read_csv(my.csv, skiprows = 1) df2 = pd.read_csv(my.csv, skiprows = [0, 2, 3])
index_col: This is to allow you to set which columns to be used as the index of the dataframe.
The default value is None, and pandas will add a new column start from 0 to specify the index
column.
sep: a shortened name for separator. This operator is the delimiter used in our dataset or in
Laymans term, how the data items are separated in our CSV file.
users = pd.read_csv('users.csv', sep='|', index_col='user_id')
In our data, columns are separated by | and we want to user user_id as index column
Step 2: Getting and Knowing your Data (1%)
Show the first 10 entries
show the last 10 entries
Print the name and data type of each column?
Print only the occupation column
How many different occupations are in this dataset?
What is the most frequently appeared occupation?
What is the mean age of users?
What is the occupation with least occurrence?
Step 3: Filtering and Sorting Data (1%)
Show only people are older than 40 years old
sort by zip_code of the user
who is/are the oldest person/people in the data frame
Step 4: Grouping (1%)
What is the mean age per occupation (round to 2 decimal places)
For each occupation, calculate the minimum and maximum ages
For each occupation present the percentage of women and men

More Related Content

Similar to code in python and explain Step 1 Import data.skiprows This pa.pdf

pandas directories on the python language.pptx
pandas directories on the python language.pptxpandas directories on the python language.pptx
pandas directories on the python language.pptx
SumitMajukar
 
Lecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learningLecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learning
my6305874
 

Similar to code in python and explain Step 1 Import data.skiprows This pa.pdf (20)

Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
 
More on Pandas.pptx
More on Pandas.pptxMore on Pandas.pptx
More on Pandas.pptx
 
Database programming
Database programmingDatabase programming
Database programming
 
Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
Python for Data Analysis.pdf
Python for Data Analysis.pdfPython for Data Analysis.pdf
Python for Data Analysis.pdf
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
 
Pandas Dataframe reading data Kirti final.pptx
Pandas Dataframe reading data  Kirti final.pptxPandas Dataframe reading data  Kirti final.pptx
Pandas Dataframe reading data Kirti final.pptx
 
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdfXII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
 
Python-for-Data-Analysis.pdf
Python-for-Data-Analysis.pdfPython-for-Data-Analysis.pdf
Python-for-Data-Analysis.pdf
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
 
Machine Learning - Simple Linear Regression
Machine Learning - Simple Linear RegressionMachine Learning - Simple Linear Regression
Machine Learning - Simple Linear Regression
 
Sas tips & tricks
Sas tips & tricksSas tips & tricks
Sas tips & tricks
 
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptxfINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 
pandas directories on the python language.pptx
pandas directories on the python language.pptxpandas directories on the python language.pptx
pandas directories on the python language.pptx
 
Lecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learningLecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learning
 
The Uniform Access Principle
The Uniform Access PrincipleThe Uniform Access Principle
The Uniform Access Principle
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
 

More from fahamritsar

complete this crossword on management. 13. Going along with p.pdf
complete this crossword on management.  13. Going along with p.pdfcomplete this crossword on management.  13. Going along with p.pdf
complete this crossword on management. 13. Going along with p.pdf
fahamritsar
 

More from fahamritsar (11)

Case Study 5 (Chapter 17) Case 17.1 Hosch v. Colonial Pacific Leasi.pdf
Case Study 5 (Chapter 17) Case 17.1 Hosch v. Colonial Pacific Leasi.pdfCase Study 5 (Chapter 17) Case 17.1 Hosch v. Colonial Pacific Leasi.pdf
Case Study 5 (Chapter 17) Case 17.1 Hosch v. Colonial Pacific Leasi.pdf
 
can you please hand draw this please and thank youProvide NFA and.pdf
can you please hand draw this please and thank youProvide NFA and.pdfcan you please hand draw this please and thank youProvide NFA and.pdf
can you please hand draw this please and thank youProvide NFA and.pdf
 
Consider a database system for SEU that stores information about stu.pdf
Consider a database system for SEU that stores information about stu.pdfConsider a database system for SEU that stores information about stu.pdf
Consider a database system for SEU that stores information about stu.pdf
 
Consider a database system for SEU that stores information about stude.pdf
Consider a database system for SEU that stores information about stude.pdfConsider a database system for SEU that stores information about stude.pdf
Consider a database system for SEU that stores information about stude.pdf
 
Complete the code, correct it in case there are errors, and when it .pdf
Complete the code, correct it in case there are errors, and when it .pdfComplete the code, correct it in case there are errors, and when it .pdf
Complete the code, correct it in case there are errors, and when it .pdf
 
Compound entriesA. would include an entry to record the purchase.pdf
Compound entriesA. would include an entry to record the purchase.pdfCompound entriesA. would include an entry to record the purchase.pdf
Compound entriesA. would include an entry to record the purchase.pdf
 
complete this crossword on management. 13. Going along with p.pdf
complete this crossword on management.  13. Going along with p.pdfcomplete this crossword on management.  13. Going along with p.pdf
complete this crossword on management. 13. Going along with p.pdf
 
Company began operations on January 1. It purchased 3 shredders as p.pdf
Company began operations on January 1. It purchased 3 shredders as p.pdfCompany began operations on January 1. It purchased 3 shredders as p.pdf
Company began operations on January 1. It purchased 3 shredders as p.pdf
 
Clarence and Victoria were divorced in 2014. Clarence was ordered to.pdf
Clarence and Victoria were divorced in 2014. Clarence was ordered to.pdfClarence and Victoria were divorced in 2014. Clarence was ordered to.pdf
Clarence and Victoria were divorced in 2014. Clarence was ordered to.pdf
 
Chapter 3 Objectives 4-7 1. Businesses us C computing to more efficlen.pdf
Chapter 3 Objectives 4-7 1. Businesses us C computing to more efficlen.pdfChapter 3 Objectives 4-7 1. Businesses us C computing to more efficlen.pdf
Chapter 3 Objectives 4-7 1. Businesses us C computing to more efficlen.pdf
 
CB Solutions.Heather OReilly, the treasurer of CB Solutions, believ.pdf
CB Solutions.Heather OReilly, the treasurer of CB Solutions, believ.pdfCB Solutions.Heather OReilly, the treasurer of CB Solutions, believ.pdf
CB Solutions.Heather OReilly, the treasurer of CB Solutions, believ.pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 

code in python and explain Step 1 Import data.skiprows This pa.pdf

  • 1. code in python and explain Step 1: Import data. skiprows: This parameter is use to skip passed rows in new data frame df1 = pd.read_csv(my.csv, skiprows = 1) df2 = pd.read_csv(my.csv, skiprows = [0, 2, 3]) index_col: This is to allow you to set which columns to be used as the index of the dataframe. The default value is None, and pandas will add a new column start from 0 to specify the index column. sep: a shortened name for separator. This operator is the delimiter used in our dataset or in Laymans term, how the data items are separated in our CSV file. users = pd.read_csv('users.csv', sep='|', index_col='user_id') In our data, columns are separated by | and we want to user user_id as index column Step 2: Getting and Knowing your Data (1%) Show the first 10 entries show the last 10 entries Print the name and data type of each column? Print only the occupation column How many different occupations are in this dataset? What is the most frequently appeared occupation? What is the mean age of users? What is the occupation with least occurrence? Step 3: Filtering and Sorting Data (1%) Show only people are older than 40 years old sort by zip_code of the user who is/are the oldest person/people in the data frame Step 4: Grouping (1%) What is the mean age per occupation (round to 2 decimal places) For each occupation, calculate the minimum and maximum ages For each occupation present the percentage of women and men