Python for Data analysis, Cheat Sheet of Database Programming

Year 2023, Python for Data analysis cheat sheet

Typology: Cheat Sheet

2022/2023

Uploaded on 08/24/2024

umer-arshad-1
umer-arshad-1 🇺🇸

1 document

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Group the data by different categories of an
ribute, displaying the average value of numerical
ributes with the same category.
Group the data by different categories of multiple
ributes, displaying the average value of numerical
ributes with the same category.
eate Pivot tables for better representation of data
sed on parameters
eate a heatmap image using a PsuedoColor plot (or
olor) using the pivot table as data.
lculate the Pearson Coefficient and p-value of a pair
attributes
1
2
3
4
5
6
a.
df_group =
df_group.groupby(['attribute_1'],as_index=False).mean()
b.
df_group = df_group.groupby(['attribute_1',
'attribute_2'],as_index=False).mean()
1
2
grouped_pivot =
df_group.pivot(index='attribute_1',columns='attribute_2')
1
2
from matlplotlib import pyplot as plt
plt.pcolor(grouped_pivot, cmap='RdBu')
1
2
3
From scipy import stats
pearson_coef,p_value=stats.pearsonr(df['attribute_1'],
df['attribute_2'])
+-

Partial preview of the text

Download Python for Data analysis and more Cheat Sheet Database Programming in PDF only on Docsity!

Group the data by different categories of an

ribute, displaying the average value of numerical

ributes with the same category.

Group the data by different categories of multiple

ributes, displaying the average value of numerical

ributes with the same category.

eate Pivot tables for better representation of data

sed on parameters

eate a heatmap image using a PsuedoColor plot (or

olor) using the pivot table as data.

lculate the Pearson Coefficient and p-value of a pair

attributes

a.

df_group =

df_group.groupby(['attribute_1'],as_index=False).mean()

b.

df_group = df_group.groupby(['attribute_1',

'attribute_2'],as_index=False).mean()

grouped_pivot =

df_group.pivot(index='attribute_1',columns='attribute_2')

from matlplotlib import pyplot as plt

plt.pcolor(grouped_pivot, cmap='RdBu')

From scipy import stats

pearson_coef,p_value=stats.pearsonr(df['attribute_1'],

df['attribute_2'])