SlideShare a Scribd company logo
PythonForDataScience Cheat Sheet
Pandas Basics
Learn Python for Data Science Interactively at www.DataCamp.com
Pandas
DataCamp
Learn Python for Data Science Interactively
Series
DataFrame
4
7
-5
3
D
C
B
AA one-dimensional labeled array
capable of holding any data type
Index
Index
Columns
A two-dimensional labeled
data structure with columns
of potentially different types
The Pandas library is built on NumPy and provides easy-to-use
data structures and data analysis tools for the Python
programming language.
>>> import pandas as pd
Use the following import convention:
Pandas Data Structures
>>> s = pd.Series([3, -5, 7, 4], index=['a', 'b', 'c', 'd'])
>>> data = {'Country': ['Belgium', 'India', 'Brazil'],
'Capital': ['Brussels', 'New Delhi', 'Brasília'],
'Population': [11190846, 1303171035, 207847528]}
>>> df = pd.DataFrame(data,
columns=['Country', 'Capital', 'Population'])
Selection
>>> s['b'] Get one element
-5
>>> df[1:] Get subset of a DataFrame
Country Capital Population
1 India New Delhi 1303171035
2 Brazil Brasília 207847528
By Position
>>> df.iloc([0],[0]) Select single value by row &
'Belgium' column
>>> df.iat([0],[0])
'Belgium'
By Label
>>> df.loc([0], ['Country']) Select single value by row &
'Belgium' column labels
>>> df.at([0], ['Country'])
'Belgium'
By Label/Position
>>> df.ix[2] Select single row of
Country Brazil subset of rows
Capital Brasília
Population 207847528
>>> df.ix[:,'Capital'] Select a single column of
0 Brussels subset of columns
1 New Delhi
2 Brasília
>>> df.ix[1,'Capital'] Select rows and columns
'New Delhi'
Boolean Indexing
>>> s[~(s > 1)] Series s where value is not >1
>>> s[(s < -1) | (s > 2)] s where value is <-1 or >2
>>> df[df['Population']>1200000000] Use filter to adjust DataFrame
Setting
>>> s['a'] = 6 Set index a of Series s to 6
Applying Functions
>>> f = lambda x: x*2
>>> df.apply(f) Apply function
>>> df.applymap(f) Apply function element-wise
Retrieving Series/DataFrame Information
>>> df.shape (rows,columns)
>>> df.index	 Describe index	
>>> df.columns Describe DataFrame columns
>>> df.info() Info on DataFrame
>>> df.count() Number of non-NA values
Getting
Also see NumPy Arrays
Selecting, Boolean Indexing & Setting Basic Information
Summary
>>> df.sum() Sum of values
>>> df.cumsum() Cummulative sum of values
>>> df.min()/df.max() Minimum/maximum values
>>> df.idmin()/df.idmax() Minimum/Maximum index value
>>> df.describe() Summary statistics
>>> df.mean() Mean of values
>>> df.median() Median of values
Dropping
>>> s.drop(['a', 'c']) Drop values from rows (axis=0)
>>> df.drop('Country', axis=1) Drop values from columns(axis=1)
Data Alignment
>>> s.add(s3, fill_value=0)
a 10.0
b -5.0
c 5.0
d 7.0
>>> s.sub(s3, fill_value=2)
>>> s.div(s3, fill_value=4)
>>> s.mul(s3, fill_value=3)
>>> s3 = pd.Series([7, -2, 3], index=['a', 'c', 'd'])
>>> s + s3
a 10.0
b NaN
c 5.0
d 7.0
Arithmetic Operations with Fill Methods
Internal Data Alignment
NA values are introduced in the indices that don’t overlap:
You can also do the internal data alignment yourself with
the help of the fill methods:
Sort & Rank
>>> df.sort_index(by='Country') Sort by row or column index
>>> s.order()		 Sort a series by its values
>>> df.rank() Assign ranks to entries
Belgium Brussels
India New Delhi
Brazil Brasília
1
2
3
Country Capital
11190846
1303171035
207847528
Population
I/O
Read and Write to CSV
>>> pd.read_csv('file.csv', header=None, nrows=5)
>>> pd.to_csv('myDataFrame.csv')
Read and Write to Excel
>>> pd.read_excel('file.xlsx')
>>> pd.to_excel('dir/myDataFrame.xlsx', sheet_name='Sheet1')
Read multiple sheets from the same file
>>> xlsx = pd.ExcelFile('file.xls')
>>> df = pd.read_excel(xlsx, 'Sheet1')
>>> help(pd.Series.loc)
Asking For Help
Read and Write to SQL Query or Database Table
>>> from sqlalchemy import create_engine
>>> engine = create_engine('sqlite:///:memory:')
>>> pd.read_sql("SELECT * FROM my_table;", engine)
>>> pd.read_sql_table('my_table', engine)
>>> pd.read_sql_query("SELECT * FROM my_table;", engine)
>>> pd.to_sql('myDf', engine)
read_sql()is a convenience wrapper around read_sql_table() and
read_sql_query()

More Related Content

What's hot (20)

PDF
Numpy python cheat_sheet
Nishant Upadhyay
 
PDF
Introduction to Python Pandas for Data Analytics
Phoenix
 
PDF
Python For Data Science Cheat Sheet
Karlijn Willems
 
PPTX
Pandas
Jyoti shukla
 
PDF
pandas: Powerful data analysis tools for Python
Wes McKinney
 
PPT
Python Pandas
Sunil OS
 
PPTX
Pandas Series
Sangita Panchal
 
PDF
Python matplotlib cheat_sheet
Nishant Upadhyay
 
PPTX
Data Analysis with Python Pandas
Neeru Mittal
 
PPTX
DataFrame in Python Pandas
Sangita Panchal
 
PPTX
Python Seaborn Data Visualization
Sourabh Sahu
 
PDF
Pandas
maikroeder
 
PPT
Chapter - 6 Data Mining Concepts and Techniques 2nd Ed slides Han &amp; Kamber
error007
 
PPT
3.1 clustering
Krish_ver2
 
PDF
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Edureka!
 
PDF
Python-Cheat-Sheet.pdf
Mohd Aves Malik
 
PPTX
Introduction to numpy Session 1
Jatin Miglani
 
PPTX
Data Visualization & Analytics.pptx
hiralpatel3085
 
PPTX
Python pandas Library
Md. Sohag Miah
 
PPTX
Apriori algorithm
Mainul Hassan
 
Numpy python cheat_sheet
Nishant Upadhyay
 
Introduction to Python Pandas for Data Analytics
Phoenix
 
Python For Data Science Cheat Sheet
Karlijn Willems
 
Pandas
Jyoti shukla
 
pandas: Powerful data analysis tools for Python
Wes McKinney
 
Python Pandas
Sunil OS
 
Pandas Series
Sangita Panchal
 
Python matplotlib cheat_sheet
Nishant Upadhyay
 
Data Analysis with Python Pandas
Neeru Mittal
 
DataFrame in Python Pandas
Sangita Panchal
 
Python Seaborn Data Visualization
Sourabh Sahu
 
Pandas
maikroeder
 
Chapter - 6 Data Mining Concepts and Techniques 2nd Ed slides Han &amp; Kamber
error007
 
3.1 clustering
Krish_ver2
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Edureka!
 
Python-Cheat-Sheet.pdf
Mohd Aves Malik
 
Introduction to numpy Session 1
Jatin Miglani
 
Data Visualization & Analytics.pptx
hiralpatel3085
 
Python pandas Library
Md. Sohag Miah
 
Apriori algorithm
Mainul Hassan
 

Viewers also liked (20)

PDF
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
PDF
Follow up SPARK
Sainu Geanina
 
PPTX
Python for Data Analysis: Chapter 2
智哉 今西
 
PPT
Statistical Test
guestdbf093
 
PPTX
Intro to Python Data Analysis in Wakari
Karissa Rae McKelvey
 
PDF
Python for Data Science
Harri Hämäläinen
 
PDF
A+ cheat sheet
abnmi
 
PDF
Linux cheat-sheet
Craig Cannon
 
DOCX
Naive Bayes Example using R
Dr. Volkan OBAN
 
PDF
Python
Vinayak Hegde
 
PDF
Advanced R cheat sheet
Dr. Volkan OBAN
 
PDF
Data Exploration and Visualization with R
Yanchang Zhao
 
PPTX
Practical Data Analysis in Python
Hilary Mason
 
PPTX
Data analysis with pandas
Outreach Digital
 
PDF
2013.06.18 Time Series Analysis Workshop ..Applications in Physiology, Climat...
NUI Galway
 
PDF
Getting started with pandas
maikroeder
 
PDF
Python Cheat Sheet
GlowTouch
 
ODP
Data Analysis in Python
Richard Herrell
 
PDF
Cheat sheets for data scientists
Ajay Ohri
 
PPTX
Python and Data Analysis
Praveen Nair
 
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
Follow up SPARK
Sainu Geanina
 
Python for Data Analysis: Chapter 2
智哉 今西
 
Statistical Test
guestdbf093
 
Intro to Python Data Analysis in Wakari
Karissa Rae McKelvey
 
Python for Data Science
Harri Hämäläinen
 
A+ cheat sheet
abnmi
 
Linux cheat-sheet
Craig Cannon
 
Naive Bayes Example using R
Dr. Volkan OBAN
 
Advanced R cheat sheet
Dr. Volkan OBAN
 
Data Exploration and Visualization with R
Yanchang Zhao
 
Practical Data Analysis in Python
Hilary Mason
 
Data analysis with pandas
Outreach Digital
 
2013.06.18 Time Series Analysis Workshop ..Applications in Physiology, Climat...
NUI Galway
 
Getting started with pandas
maikroeder
 
Python Cheat Sheet
GlowTouch
 
Data Analysis in Python
Richard Herrell
 
Cheat sheets for data scientists
Ajay Ohri
 
Python and Data Analysis
Praveen Nair
 
Ad

Similar to Python Pandas for Data Science cheatsheet (20)

PDF
2 pandasbasic
pramod naik
 
PDF
Pandas pythonfordatascience
Nishant Upadhyay
 
PDF
PyData Paris 2015 - Track 1.2 Gilles Louppe
Pôle Systematic Paris-Region
 
PPTX
pandasppt with informative topics coverage.pptx
vallarasu200364
 
PDF
pandas dataframe notes.pdf
AjeshSurejan2
 
PPTX
dvdxsfdxfdfdfdffddvfbgbesseesesgesesseseggesges
iapreddy2004
 
PPTX
Pandas yayyyyyyyyyyyyyyyyyin Python.pptx
AamnaRaza1
 
PPTX
Pandas Dataframe reading data Kirti final.pptx
Kirti Verma
 
PPTX
introduction to data structures in pandas
vidhyapm2
 
PDF
Pandas cheat sheet
Lenis Carolina Lopez
 
PDF
Pandas cheat sheet_data science
Subrata Shaw
 
PDF
Data Wrangling with Pandas
Luis Carrasco
 
PPTX
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
HarshitChauhan88
 
PDF
pandas-221217084954-937bb582.pdf
scorsam1
 
PPTX
Pandas.pptx
Govardhan Bhavani
 
PPTX
Presentation on the basic of numpy and Pandas
ipazhaniraj
 
PPTX
Pandas.pptx
Ramakrishna Reddy Bijjam
 
PPTX
ppanda.pptx
DOLKUMARCHANDRA
 
PPTX
Python libraries for analysis Pandas.pptx
rahulborate13
 
PPTX
Introduction to pandas
Piyush rai
 
2 pandasbasic
pramod naik
 
Pandas pythonfordatascience
Nishant Upadhyay
 
PyData Paris 2015 - Track 1.2 Gilles Louppe
Pôle Systematic Paris-Region
 
pandasppt with informative topics coverage.pptx
vallarasu200364
 
pandas dataframe notes.pdf
AjeshSurejan2
 
dvdxsfdxfdfdfdffddvfbgbesseesesgesesseseggesges
iapreddy2004
 
Pandas yayyyyyyyyyyyyyyyyyin Python.pptx
AamnaRaza1
 
Pandas Dataframe reading data Kirti final.pptx
Kirti Verma
 
introduction to data structures in pandas
vidhyapm2
 
Pandas cheat sheet
Lenis Carolina Lopez
 
Pandas cheat sheet_data science
Subrata Shaw
 
Data Wrangling with Pandas
Luis Carrasco
 
Group B - Pandas Pandas is a powerful Python library that provides high-perfo...
HarshitChauhan88
 
pandas-221217084954-937bb582.pdf
scorsam1
 
Pandas.pptx
Govardhan Bhavani
 
Presentation on the basic of numpy and Pandas
ipazhaniraj
 
ppanda.pptx
DOLKUMARCHANDRA
 
Python libraries for analysis Pandas.pptx
rahulborate13
 
Introduction to pandas
Piyush rai
 
Ad

More from Dr. Volkan OBAN (20)

PDF
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
PDF
Covid19py Python Package - Example
Dr. Volkan OBAN
 
PDF
Object detection with Python
Dr. Volkan OBAN
 
PDF
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
DOCX
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
DOCX
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
DOCX
k-means Clustering in Python
Dr. Volkan OBAN
 
DOCX
R forecasting Example
Dr. Volkan OBAN
 
DOCX
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
PDF
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
DOCX
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
PDF
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
DOCX
R-ggplot2 package Examples
Dr. Volkan OBAN
 
DOCX
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
DOCX
treemap package in R and examples.
Dr. Volkan OBAN
 
DOCX
Mosaic plot in R.
Dr. Volkan OBAN
 
DOCX
imager package in R and examples..
Dr. Volkan OBAN
 
PDF
R-Data table Cheat Sheet
Dr. Volkan OBAN
 
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
Covid19py Python Package - Example
Dr. Volkan OBAN
 
Object detection with Python
Dr. Volkan OBAN
 
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
k-means Clustering in Python
Dr. Volkan OBAN
 
R forecasting Example
Dr. Volkan OBAN
 
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
R-ggplot2 package Examples
Dr. Volkan OBAN
 
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
treemap package in R and examples.
Dr. Volkan OBAN
 
Mosaic plot in R.
Dr. Volkan OBAN
 
imager package in R and examples..
Dr. Volkan OBAN
 
R-Data table Cheat Sheet
Dr. Volkan OBAN
 

Recently uploaded (20)

PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PPTX
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PDF
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
PDF
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPTX
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PDF
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 

Python Pandas for Data Science cheatsheet

  • 1. PythonForDataScience Cheat Sheet Pandas Basics Learn Python for Data Science Interactively at www.DataCamp.com Pandas DataCamp Learn Python for Data Science Interactively Series DataFrame 4 7 -5 3 D C B AA one-dimensional labeled array capable of holding any data type Index Index Columns A two-dimensional labeled data structure with columns of potentially different types The Pandas library is built on NumPy and provides easy-to-use data structures and data analysis tools for the Python programming language. >>> import pandas as pd Use the following import convention: Pandas Data Structures >>> s = pd.Series([3, -5, 7, 4], index=['a', 'b', 'c', 'd']) >>> data = {'Country': ['Belgium', 'India', 'Brazil'], 'Capital': ['Brussels', 'New Delhi', 'Brasília'], 'Population': [11190846, 1303171035, 207847528]} >>> df = pd.DataFrame(data, columns=['Country', 'Capital', 'Population']) Selection >>> s['b'] Get one element -5 >>> df[1:] Get subset of a DataFrame Country Capital Population 1 India New Delhi 1303171035 2 Brazil Brasília 207847528 By Position >>> df.iloc([0],[0]) Select single value by row & 'Belgium' column >>> df.iat([0],[0]) 'Belgium' By Label >>> df.loc([0], ['Country']) Select single value by row & 'Belgium' column labels >>> df.at([0], ['Country']) 'Belgium' By Label/Position >>> df.ix[2] Select single row of Country Brazil subset of rows Capital Brasília Population 207847528 >>> df.ix[:,'Capital'] Select a single column of 0 Brussels subset of columns 1 New Delhi 2 Brasília >>> df.ix[1,'Capital'] Select rows and columns 'New Delhi' Boolean Indexing >>> s[~(s > 1)] Series s where value is not >1 >>> s[(s < -1) | (s > 2)] s where value is <-1 or >2 >>> df[df['Population']>1200000000] Use filter to adjust DataFrame Setting >>> s['a'] = 6 Set index a of Series s to 6 Applying Functions >>> f = lambda x: x*2 >>> df.apply(f) Apply function >>> df.applymap(f) Apply function element-wise Retrieving Series/DataFrame Information >>> df.shape (rows,columns) >>> df.index Describe index >>> df.columns Describe DataFrame columns >>> df.info() Info on DataFrame >>> df.count() Number of non-NA values Getting Also see NumPy Arrays Selecting, Boolean Indexing & Setting Basic Information Summary >>> df.sum() Sum of values >>> df.cumsum() Cummulative sum of values >>> df.min()/df.max() Minimum/maximum values >>> df.idmin()/df.idmax() Minimum/Maximum index value >>> df.describe() Summary statistics >>> df.mean() Mean of values >>> df.median() Median of values Dropping >>> s.drop(['a', 'c']) Drop values from rows (axis=0) >>> df.drop('Country', axis=1) Drop values from columns(axis=1) Data Alignment >>> s.add(s3, fill_value=0) a 10.0 b -5.0 c 5.0 d 7.0 >>> s.sub(s3, fill_value=2) >>> s.div(s3, fill_value=4) >>> s.mul(s3, fill_value=3) >>> s3 = pd.Series([7, -2, 3], index=['a', 'c', 'd']) >>> s + s3 a 10.0 b NaN c 5.0 d 7.0 Arithmetic Operations with Fill Methods Internal Data Alignment NA values are introduced in the indices that don’t overlap: You can also do the internal data alignment yourself with the help of the fill methods: Sort & Rank >>> df.sort_index(by='Country') Sort by row or column index >>> s.order() Sort a series by its values >>> df.rank() Assign ranks to entries Belgium Brussels India New Delhi Brazil Brasília 1 2 3 Country Capital 11190846 1303171035 207847528 Population I/O Read and Write to CSV >>> pd.read_csv('file.csv', header=None, nrows=5) >>> pd.to_csv('myDataFrame.csv') Read and Write to Excel >>> pd.read_excel('file.xlsx') >>> pd.to_excel('dir/myDataFrame.xlsx', sheet_name='Sheet1') Read multiple sheets from the same file >>> xlsx = pd.ExcelFile('file.xls') >>> df = pd.read_excel(xlsx, 'Sheet1') >>> help(pd.Series.loc) Asking For Help Read and Write to SQL Query or Database Table >>> from sqlalchemy import create_engine >>> engine = create_engine('sqlite:///:memory:') >>> pd.read_sql("SELECT * FROM my_table;", engine) >>> pd.read_sql_table('my_table', engine) >>> pd.read_sql_query("SELECT * FROM my_table;", engine) >>> pd.to_sql('myDf', engine) read_sql()is a convenience wrapper around read_sql_table() and read_sql_query()