Pythonを一から勉強してデータ分析できるようになる

~ Pythonとデータ分析のお勉強の記録 ~

便利なヒストグラム seaborn を使う

[Take0] 練習用データの定義とプロット

 

【書式】

ライブラリ:pandas,matplotlib,seaborn
書式
sns.distplot(df["列名"],fit=norm,fit_kws={"color":"色"})
plt.show()

 

【コード】

%matplotlib inline
import matplotlib.pyplot as plt
import japanize_matplotlib
import seaborn as sns
import pandas as pd
import numpy as np
from scipy.stats import norm
 
df=pd.DataFrame({
    "A":np.random.randint(0,100,1500),
    "B":np.random.normal(50,10,1500)
})
 
sns.distplot(df["A"],fit=norm,fit_kws={"color":"red"})
plt.title("偏りのないランダムな値")
plt.show()
 
sns.distplot(df["B"],fit=norm,fit_kws={"color":"red"})
plt.title("偏りのないランダムな値")
plt.show()

 

【結果】

:14: UserWarning:
 
`distplot` is a deprecated function and will be removed in seaborn v0.14.0.
 
Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `histplot` (an axes-level function for histograms).
 
For a guide to updating your code to use the new functions, please see
 
sns.distplot(df["A"],fit=norm,fit_kws={"color":"red"})

:18: UserWarning:
 
`distplot` is a deprecated function and will be removed in seaborn v0.14.0.
 
Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `histplot` (an axes-level function for histograms).
 
For a guide to updating your code to use the new functions, please see
 
sns.distplot(df["B"],fit=norm,fit_kws={"color":"red"})

 

微妙なメッセージが出たが、現段階では流すことにする。