Tuesday, August 30, 2022

Some Usefull Pandas Formula

 # data.info()

use for displaying Column Name,[Data type], null/Non/Null


#data.describe().T
use to display Mean,Median Mode, Percentile,Min and max Value

#data.corr().style.background_gradient(cmap='coolwarm')
use to Display and Calculate Correlation among Columns,

#data.isna()
for finding null value in columns

#data.isna().sum()

for displaying total null values in columns


#data['classification'].unique()

to display Unique Value

#data[['classification','id']].groupby('classification').count()

to display Count value group by naother column


#data.drop(['id','rbc'],axis=1,inplace=True)
droping Columns

#data['age'].mean()

calculating Mean of Column

#data['dm'].replace(to_replace = {' yes':'yes'},inplace=True)

replacing a value with another value


#data['appet'].fillna( data['appet'].mode()[0], inplace=True)

Filling Null Value with Mode


# for col in data.columns:
    print(f"{col} has {data[col].unique()} values\n")


Displaying all columns Unique Value



#
g = sns.PairGrid(data)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)

Displaying Pair Plot


#sns.catplot(x="classification", y="age",data=data,hue='appet',col='htn')

Displaying Category Plot


#sns.boxplot(x='htn',y='age',data=notchk_age)

Displaying Box Plot

No comments:

Post a Comment