pip install pandas
Getting the version of Pandas
import pandas as pd
print("Pandas Version : ",pd.__version__)
Upgrade Pandas
pip install --upgrade pandas
Data statistics, filtering, Aggregation and grouping, data merging and joining etc.
Data AnalysisHandling Null, NaN data, finding duplicate data, replacing data and more .
Data CleaningExercise1 | Basic data handling , DataFrame |
Exercise1-1 | Using cut(), groupby and plotting graphs |
Exercise-Adv | Using groupby and merge of DataFrame |
Exercise2 | Using str.contains(), max(), min(),len() of DataFrame |
Exercise3 | Using date and time functions with groupby of DataFrame |
Exercise3-2 | Using date and time functions of DataFrame |
Exercise3-3 | Using date and time functions with groupby |
Exercise3-4 | Using date and time with where timedelta64 |
loc | Values at different position using column label |
rows | Filtering rows based on data |
str.contains | string matching against data columns |
str.contains.sum | Max Min Sum of any column |
Convert Case | Lower to Upper and vice versa |
split() | Breaking string using delimiter |
slice() | Substring by breaking string |
cat() | Concatenate strings |
count() | Number of occurrences of pattern |
replace() | Replace part of string by regex |
len() | Length of the data in our DataFrame |
zfill() | Prepending string with '0' |
Pandas Date and time | Managing Date and time in Pandas DataFrame |
import pandas as pd
my_data = pd.read_excel('D:\emp.xlsx')
# reading data from root of D drive.
from sqlalchemy import create_engine
my_conn = create_engine("mysql+mysqldb://userid:password@localhost/database_name")
### Creating new table emp or appending existing table
my_data.to_sql(con=my_conn,name='emp',if_exists='append')
import pandas as pd
from sqlalchemy import create_engine
my_conn = create_engine("mysql+mysqldb://userid:password@localhost/database_name")
sql="SELECT * FROM emp "
my_data = pd.read_sql(sql,my_conn )
my_data.to_excel('D:\emp2.xlsx')
columns | List of column headers of a DataFrame |
rename | rename columns of DataFrame |
add_suffix | adding suffix to column names of a DataFrame |
add_prefix | adding prefix to column names of a DataFrame |
drop | Delete columns or rows |
import pandas as pd
print(len(dir(pd))) # 139
for i in dir(pd):
print(i)
Pandas DataFrame inplace | Boolean ( True / False ), Result is written back to same dataframe ( True ). The source dataframe is changed. False otherwise. |
Section | Details | Download |
---|---|---|
A | Introduction | Download |