Professional Documents
Culture Documents
Script TugasStatistika1B Kelompok4
Script TugasStatistika1B Kelompok4
1165]
C:\Users\asus>python --version
Python 3.9.7
Collecting pandas
Collecting python-dateutil>=2.7.3
Collecting numpy>=1.17.3
Collecting pytz>=2017.3
Collecting six>=1.5
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
Collecting seaborn
Collecting matplotlib>=2.2
Collecting scipy>=1.0
Collecting pillow>=6.2.0
Collecting kiwisolver>=1.0.1
Collecting pyparsing>=2.2.1
Collecting cycler>=0.10
Installing collected packages: pyparsing, pillow, kiwisolver, cycler, scipy, matplotlib, seaborn
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
C:\Users\asus>python
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32
>>> df=pd.read_csv("Downloads\CJ_SiMg.csv")
>>> df.head(5)
>>> df.describe()
SiO2 MgO
>>> df.median()
SiO2 54.100000
MgO 2.830925
dtype: float64
>>> plt.show()
>>> min=df['SiO2'].min()
>>> max=df['SiO2'].max()
>>> print(min)
44.78905
>>> print(max)
75.3
>>> sturgesCI=1+((3.3)*np.log(670))
>>> print(sturgesCI)
22.474016450870536
>>> plt.show()
>>> plt.show()
>>> class_int=1+((3.3)*np.log(670))
>>> print(class_int)
22.474016450870536
>>> print(CI)
0 (50.095, 51.422]
1 (58.055, 59.381]
2 (52.748, 54.075]
3 (56.728, 58.055]
4 (62.034, 63.361]
...
Categories (23, interval[float64, right]): [(44.759, 46.116] < (46.116, 47.442] < (47.442, 48.769] <
>>> pd.value_counts(CI)
(55.402, 56.728] 83
(51.422, 52.748] 81
(50.095, 51.422] 67
(56.728, 58.055] 26
(48.769, 50.095] 25
(60.708, 62.034] 17
(47.442, 48.769] 15
(59.381, 60.708] 12
(58.055, 59.381] 11
(62.034, 63.361] 9
(63.361, 64.687] 9
(44.759, 46.116] 9
(46.116, 47.442] 8
(73.973, 75.3] 5
(66.014, 67.341] 2
(71.32, 72.647] 2
(64.687, 66.014] 1
(67.341, 68.667] 0
(68.667, 69.994] 0
(69.994, 71.32] 0
(72.647, 73.973] 0
>>> df2=pd.value_counts(CI)
>>> df2.to_excel("Tugas.xlsx")
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\
generic.py", line 2284, in to_excel
formatter.write(
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\formats\
excel.py", line 834, in write
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\
_openpyxl.py", line 48, in __init__
<AxesSubplot:xlabel='SiO2', ylabel='Proportion'>
>>> plt.show()
<AxesSubplot:xlabel='SiO2', ylabel='Proportion'>
>>> plt.show()
>>> ar_mean=mean(df)
<stdin>:1: DeprecationWarning: scipy.mean is deprecated and will be removed in SciPy 2.0.0, use
numpy.mean instead
C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core\
fromnumeric.py:3438: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with
'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid
columns before calling the reduction.
return mean(axis=axis, dtype=dtype, out=out, **kwargs)
>>> print(ar_mean)
SiO2 54.258760
MgO 3.040846
dtype: float64
>>> x=df["SiO2"].values #
>>> geo_mean=gmean(x)
>>> print(geo_mean)
54.12558033650767
>>> har_mean=hmean(x)
>>> print(har_mean)
53.99898217964356
>>> mode(df)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
_decorators.py", line 46, in inner_f
return f(**kwargs)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 2243, in boxplot
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 406, in __init__
raise ValueError(err)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
_decorators.py", line 46, in inner_f
return f(**kwargs)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 2243, in boxplot
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 406, in __init__
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 153, in establish_variables
raise ValueError(err)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
_decorators.py", line 46, in inner_f
return f(**kwargs)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 2243, in boxplot
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 406, in __init__
raise ValueError(err)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
_decorators.py", line 46, in inner_f
return f(**kwargs)
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 3004, in swarmplot
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 1172, in __init__
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\seaborn\
categorical.py", line 153, in establish_variables
raise ValueError(err)
>>>