2 views
in Python

I have a dataset underneath and I needed to perform univariate analysis on Income Category as the example plot shown. Here the fact is in the Number category 1 is treated as Male and 0 will be treated as female.

Is there any path conceivable to solve this.

Income  Population  Number  Category

54        77           1       A

23        88           1       A

44        87           0       B

55        88           0       B

66        89           1       B

73        90           0       A

12        89           1       C

34        9            0       C

54        77           1       A

23        88           1       A

44        87           0       B

55        88           0       B

66        89           1       B

73        90           0       A

12        89           1       C

34        9            0       C

by (26.4k points)

Try the below code, which is basically used to perform Bivariate and Univariate analysis.

import seaborn as sns

import numpy as np

import pandas as pd

df = pd.DataFrame({'Income': [54,23,44,55,66,],

'Population':[77,88,87,88,89],

'Number':[1,1,0,0],

'Category':['A','A','B','B','C']})

### Univariate analysis

sns.distplot(df.Income) # numeric

sns.boxplot(df.Income) # numeric

sns.distplot(df.Population)

sns.countplot(df.Category) # categorical

sns.countplot(df.Number)

## Bivariate analysis

sns.jointplot('Income', 'Population', data = df, kind='scatter')

sns.lmplot(df.Income, df.Population, data=df, hue='Number', fit_reg=False)

sns.countplot(Category, hue = 'Number', data=df)

## Multivariate analysis

sns.pairplot(df.select_dtypes(include=[np.int, np.float]])

Are you looking for a good python tutorial? Join the python course fast and gain more knowledge in python.