SlideShare a Scribd company logo
1 of 18
We can use read_csv() function to read data from a CSV file in our DataFrame by using
<DF>=pandas.read_csv(<FilePath>)
We can use read_csv() function to read data from a CSV file in our DataFrame by using
<DF>=pandas.read_csv(<FilePath>, names=<sequence containing column names>)
We can use read_csv() function to read data from a CSV file in our DataFrame by using
<DF>=pandas.read_csv(<FilePath>, names=None>)
If names=None is
specified in read_csv
function, first row
will be taken as
column header in
DataFrame
We can use read_csv() function to read data from a CSV file in our DataFrame by using
<DF>=pandas.read_csv(<FilePath>, header=None>)
If header=None is
specified in read_csv
function, column
header in DataFrame
will in labeled as
index form 0,1,2..
and so on.
Now ,this not the output we wanted,
We wants an output as following
If, in read_csv() if you want following
output
Then, simply, use the following
<DF>=pandas.read_csv(<FilePath>,
names=<sequence of column headings>,
skiprows=<n>)
skiprows argument can take either a
number for rows to be skipped from beginning
or
It can take list of rows number to be skipped
Row 0 will not be
removed , since it
column heading
specified in
names argument
We can use read_csv() function to read data from a CSV file in our DataFrame by using
<DF>=pandas.read_csv(<FilePath>, header=None>, skiprow=<n>)
Here, we have specified
“header=None”, the python read all
the rows from CSV file. , column header
in DataFrame will in labeled as index
form 0,1,2.. and so on.
Here, we have specified “skiporws=2”,
the python will skip first 2 rows from
CSV file.
<DF>=pandas.read_csv(<FilePath>, header=None>, skiprow=<n>)
Skiprows argument can either take a number from number of rows to be skipped from
beginning or it take a list of rows number to be skipped eg. 1st, 3rd and 5th .
Ex 1. Write a program to read from a CSV file employee.csv and create a DataFrame from it.
Ex 2. Write a program to read from a CSV file employee.csv and create a DataFrame from it
but DataFrame should not use file’s column header rather should use own column number
as 0,1,2, and so on.
Ex. 3 Write a program to read from CSV file employee.csv and create a dataframe from it. Use
Empno column as labels
skiprows=1, is not mentioned so,
first row is not eleminted in
output, although, names
argument is passed
Ex 4 Write a program to read from CSV file employee.csv and create a dataframe from it. But
dataframe should not use files columns header rather should own columns heading as
“EmpID”,” EmpName”, “Designation” and “Salary”. Also Print the maximum salary given to an
employee.
Ex 4 Write a program to read from CSV file employee.csv and create a dataframe from it. But
dataframe should not use files columns header rather should own columns heading as
“EmpID”,” EmpName”, “Designation” and “Salary”. Also Print the maximum salary given to an
employee.
Ex6 PgNo 252

More Related Content

Similar to Reading_csv.pptx

Data export in matlab alvian zainuddin
Data export in matlab alvian zainuddinData export in matlab alvian zainuddin
Data export in matlab alvian zainuddin
Alvianzainuddin
 
code in python and explain Step 1 Import data.skiprows This pa.pdf
code in python and explain Step 1 Import data.skiprows This pa.pdfcode in python and explain Step 1 Import data.skiprows This pa.pdf
code in python and explain Step 1 Import data.skiprows This pa.pdf
fahamritsar
 
1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf
anilart346
 

Similar to Reading_csv.pptx (20)

Pandas-(Ziad).pptx
Pandas-(Ziad).pptxPandas-(Ziad).pptx
Pandas-(Ziad).pptx
 
Python Pandas.pptx
Python Pandas.pptxPython Pandas.pptx
Python Pandas.pptx
 
Mysql
MysqlMysql
Mysql
 
CSV Files-1.pdf
CSV Files-1.pdfCSV Files-1.pdf
CSV Files-1.pdf
 
Data export in matlab alvian zainuddin
Data export in matlab alvian zainuddinData export in matlab alvian zainuddin
Data export in matlab alvian zainuddin
 
Import and Export Big Data using R Studio
Import and Export Big Data using R StudioImport and Export Big Data using R Studio
Import and Export Big Data using R Studio
 
Unit 2 web technologies
Unit 2 web technologiesUnit 2 web technologies
Unit 2 web technologies
 
SAS cheat sheet
SAS cheat sheetSAS cheat sheet
SAS cheat sheet
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
 
code in python and explain Step 1 Import data.skiprows This pa.pdf
code in python and explain Step 1 Import data.skiprows This pa.pdfcode in python and explain Step 1 Import data.skiprows This pa.pdf
code in python and explain Step 1 Import data.skiprows This pa.pdf
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Language
 
CSV_FILES.pptx
CSV_FILES.pptxCSV_FILES.pptx
CSV_FILES.pptx
 
1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf
 
BAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureBAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 Lecture
 
Dealing with files in python specially CSV files
Dealing with files in python specially CSV filesDealing with files in python specially CSV files
Dealing with files in python specially CSV files
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
 
Matlab practical ---6.pdf
Matlab practical ---6.pdfMatlab practical ---6.pdf
Matlab practical ---6.pdf
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 

Recently uploaded

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Recently uploaded (20)

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 

Reading_csv.pptx

  • 1.
  • 2.
  • 3. We can use read_csv() function to read data from a CSV file in our DataFrame by using <DF>=pandas.read_csv(<FilePath>)
  • 4.
  • 5. We can use read_csv() function to read data from a CSV file in our DataFrame by using <DF>=pandas.read_csv(<FilePath>, names=<sequence containing column names>)
  • 6. We can use read_csv() function to read data from a CSV file in our DataFrame by using <DF>=pandas.read_csv(<FilePath>, names=None>) If names=None is specified in read_csv function, first row will be taken as column header in DataFrame
  • 7. We can use read_csv() function to read data from a CSV file in our DataFrame by using <DF>=pandas.read_csv(<FilePath>, header=None>) If header=None is specified in read_csv function, column header in DataFrame will in labeled as index form 0,1,2.. and so on.
  • 8. Now ,this not the output we wanted, We wants an output as following If, in read_csv() if you want following output Then, simply, use the following <DF>=pandas.read_csv(<FilePath>, names=<sequence of column headings>, skiprows=<n>)
  • 9. skiprows argument can take either a number for rows to be skipped from beginning or It can take list of rows number to be skipped Row 0 will not be removed , since it column heading specified in names argument
  • 10. We can use read_csv() function to read data from a CSV file in our DataFrame by using <DF>=pandas.read_csv(<FilePath>, header=None>, skiprow=<n>) Here, we have specified “header=None”, the python read all the rows from CSV file. , column header in DataFrame will in labeled as index form 0,1,2.. and so on. Here, we have specified “skiporws=2”, the python will skip first 2 rows from CSV file.
  • 11. <DF>=pandas.read_csv(<FilePath>, header=None>, skiprow=<n>) Skiprows argument can either take a number from number of rows to be skipped from beginning or it take a list of rows number to be skipped eg. 1st, 3rd and 5th .
  • 12. Ex 1. Write a program to read from a CSV file employee.csv and create a DataFrame from it.
  • 13. Ex 2. Write a program to read from a CSV file employee.csv and create a DataFrame from it but DataFrame should not use file’s column header rather should use own column number as 0,1,2, and so on.
  • 14. Ex. 3 Write a program to read from CSV file employee.csv and create a dataframe from it. Use Empno column as labels
  • 15. skiprows=1, is not mentioned so, first row is not eleminted in output, although, names argument is passed Ex 4 Write a program to read from CSV file employee.csv and create a dataframe from it. But dataframe should not use files columns header rather should own columns heading as “EmpID”,” EmpName”, “Designation” and “Salary”. Also Print the maximum salary given to an employee.
  • 16. Ex 4 Write a program to read from CSV file employee.csv and create a dataframe from it. But dataframe should not use files columns header rather should own columns heading as “EmpID”,” EmpName”, “Designation” and “Salary”. Also Print the maximum salary given to an employee.
  • 17.