Python Pandas
Pandas : Python Data analysis tool.

Getting the version of Pandas
import pandas as pd 
print("Pandas Version : ",pd.__version__)
Filtering columns and create new DataFrame
my_new = my_data.filter(['equipment','category'],axis=1)
Displaying columns of the DataFrame
Number of rows in DataFrame.
DataFramePandas DataFrame
Settings Managing DataFrame display option values
apply Applying function along an Axis or elements
atGet and Set data using rows and columns
astypeCast to a specified dtype
cutUsing segments for categorizing values
describeDescriptive statistics of DataFrame or series
groupbycombining data and aggregate functions
get_dummiesConvert categorical variable into dummy/indicator variables
headFirst n rows of the DataFrame
isnullChecking NaN or None data
ilocValues at different position using integer
infoDetail information about the Dataframe
locValues at different position using column label
filterCondition based filtering of rows
fillnaFilling NaN data
mergecombining DataFrame and aggregate functions
methodsPandas DataFrame methods
nlargestn elements in descending sorted values
maskconditional replacement of data
queryFiltering data by using conditions
sort_valuesSort columns in ascending or descending
countNumber of rows or columns with different options
maxMax value of requried axis
meanMean value of requried axis
minMin value of requried axis
stdStandard Deviation on required axis
sumSum of values of requried axis
set_indexCreating index using one or more columns
notnullNot None and Not Null values checking
reset_indexRemove index of the DataFrame
value_countscounts of unique values
uniqueUnique Data of a column
whereData updation based on condition

Creating Pandas DataFrame by using Numpy ndarray

Exercise1Basic data handling , DataFrame
Exercise1-1Using cut(), groupby and plotting graphs
Exercise-AdvUsing groupby and merge of DataFrame
Exercise2Using str.contains(), max(), min(),len() of DataFrame
Exercise3Using date and time functions with groupby of DataFrame
Exercise3-2Using date and time functions of DataFrame
Exercise3-3Using date and time functions with groupby
Exercise3-4Using date and time with where timedelta64

I/O : Input and output Data from Pandas ( Excel , MySQL , JSon)

We can’t store data in Pandas DataFrame. We can process the data by using Pandas DataFrame after reading data from different sources. Similarly after processing we can save data in different files or database by using available tools.
Data input and output from Pandas DataFrame
Filtering records
locValues at different position using column label
rowsFiltering rows based on data

handling string using str methods

str.containsstring matching against data columns
str.contains.sumMax Min Sum of any column
Convert CaseLower to Upper and vice versa
split()Breaking string using delimiter
slice()Substring by breaking string
cat()Concatenate strings
count()Number of occurences of pattern
replace()Replace part of string by regex
len()Length of the data in our DataFrame
Plotting Graphs using Data
Plotting graphsCreating different type of graphs using DataFrame
ExerciseGraph using data from Excel file
Managing Date
Pandas Date and time Managing Date and time in Pandas DataFrame

Excel to MySQL

Excel to MySQL
import pandas as pd 
my_data = pd.read_excel('D:\emp.xlsx')
# reading data from root of D drive. 
from sqlalchemy import create_engine
engine = create_engine("mysql+mysqldb://userid:password@localhost/my_tutorial")

### Creating new table emp or appending existing table 

MySQL to Excel

MySQL to Excel
import pandas as pd 

from sqlalchemy import create_engine
engine = create_engine("mysql+mysqldb://userid:password@localhost/my_tutorial")

sql="SELECT * FROM emp "
my_data = pd.read_sql(sql,engine )


Columns and rows

columnsList of column headers of a DataFrame
renamerename columns of DataFrame
add_suffixadding suffix to column names of a DataFrame
add_prefixadding prefix to column names of a DataFrame
dropDelete columns or rows

Data Cleaning

Various methods in Pandas to clean data. Read from different sources then remove or fill with matching data in rows and columns

Get the list of all functions of Pandas. ( Used dir() )
import pandas as pd
print(len(dir(pd))) # 139
for i in dir(pd):
Pandas DataFrame

Parameters of functions

There are some common parameters used in Pandas functions. Understanding them will help in quick learning of functionality.
inplaceBoolean ( True / False ), Result is written back to same dataframe ( True ). The source dataframe is changed. False otherwise.

Post your comments , suggestion , error , requirements etc here

We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 All rights reserved worldwide Privacy Policy Disclaimer