Professional Documents
Culture Documents
Data Munging - Ipynb - Colaboratory - Yodhi Adhi Sanjaya
Data Munging - Ipynb - Colaboratory - Yodhi Adhi Sanjaya
Data Munging - Ipynb - Colaboratory - Yodhi Adhi Sanjaya
ipynb - Colaboratory
print(Nama,NPM)
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force
cd /content/drive/My Drive/Python-Data-Science-Essentials-Third-Edition-master/Chapter2
/content/drive/My Drive/Python-Data-Science-Essentials-Third-Edition-master/Chapter2
import pandas as pd
iris_filename = 'regression-datasets-housing.csv'
df = pd.read_csv(iris_filename, sep=',', decimal='.', header=None)
print(df)
0 1 2 3 4 5 ... 8 9 10 11 12 13
0 0.00632 18 2.31 0 0.538 6.575 ... 1 296 15 396.90 4.98 24.0
1 0.02731 0 7.07 0 0.469 6.421 ... 2 242 17 396.90 9.14 21.6
2 0.02729 0 7.07 0 0.469 7.185 ... 2 242 17 392.83 4.03 34.7
3 0.03237 0 2.18 0 0.458 6.998 ... 3 222 18 394.63 2.94 33.4
4 0.06905 0 2.18 0 0.458 7.147 ... 3 222 18 396.90 5.33 36.2
.. ... .. ... .. ... ... ... .. ... .. ... ... ...
501 0.06263 0 11.93 0 0.573 6.593 ... 1 273 21 391.99 9.67 22.4
502 0.04527 0 11.93 0 0.573 6.120 ... 1 273 21 396.90 9.08 20.6
503 0.06076 0 11.93 0 0.573 6.976 ... 1 273 21 396.90 5.64 23.9
504 0.10959 0 11.93 0 0.573 6.794 ... 1 273 21 393.45 6.48 22.0
505 0.04741 0 11.93 0 0.573 6.030 ... 1 273 21 396.90 7.88 11.9
type(df)
pandas.core.frame.DataFrame
df.shape
(506, 14)
https://colab.research.google.com/drive/1-lZ0Q5iCEUVJkdLT-E4xtjVO4p6Du-Ei?authuser=1#scrollTo=AAL3VUCBEAjS&printMode=true 1/4
11/18/2020 Data Munging.ipynb - Colaboratory
0 1 2 3 4 5 6 7 8 9 10 11 12 13
16 1.05393 0 8.14 0 0.538 5.935 29.3 4.4986 4 307 21 386.85 6.58 23.1
20 1.25179 0 8.14 0 0.538 5.570 98.1 3.7979 4 307 21 376.57 21.02 13.6
22 1.23247 0 8.14 0 0.538 6.142 91.7 3.9769 4 307 21 396.90 18.72 15.2
29 1.00245 0 8.14 0 0.538 6.674 87.3 4.2390 4 307 21 380.23 11.98 21.0
30 1.13081 0 8.14 0 0.538 5.713 94.1 4.2330 4 307 21 360.17 22.60 12.7
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
483 2.81838 0 18.10 0 0.532 5.762 40.3 4.0983 24 666 20 392.92 10.42 21.8
484 2.37857 0 18.10 0 0.583 5.871 41.9 3.7240 24 666 20 370.73 13.34 20.6
type(filtered_column1)
485 3.67367 0 18.10 0 0.583 6.312 51.9 3.9917 24 666 20 388.62 10.58 21.2
pandas.core.frame.DataFrame
486 5.69175 0 18.10 0 0.583 6.114 79.8 3.5459 24 666 20 392.68 14.98 19.1
174 rows
(174, × 14 columns
14)
df1 = filtered_column1
filt d l 2 df [df [ 2] t (i t) 80]
https://colab.research.google.com/drive/1-lZ0Q5iCEUVJkdLT-E4xtjVO4p6Du-Ei?authuser=1#scrollTo=AAL3VUCBEAjS&printMode=true 2/4
11/18/2020 Data Munging.ipynb - Colaboratory
filtered_column2 = df1[df1[12].astype(int)==80]
filtered_column2
0 1 2 3 4 5 6 7 8 9 10 11 12 13
(0, 14)
df1 = filtered_column1
filtered_column3 = df1[df1[12].astype(int)==8]
filtered_column3
0 1 2 3 4 5 6 7 8 9 10 11 12 13
372 8.26725 0 18.1 1 0.668 5.875 89.6 1.1296 24 666 20 347.88 8.88 50.0
(1, 14)
df1 = filtered_column1
filtered_column4 = df1[df1[12].astype(int)==6]
filtered_column4
0 1 2 3 4 5 6 7 8 9 10 11 12 13
16 1.05393 0 8.14 0 0.538 5.935 29.3 4.4986 4 307 21 386.85 6.58 23.1
158 1.34284 0 19.58 0 0.605 6.066 100.0 1.7573 5 403 14 353.89 6.43 24.3
(2, 14)
https://colab.research.google.com/drive/1-lZ0Q5iCEUVJkdLT-E4xtjVO4p6Du-Ei?authuser=1#scrollTo=AAL3VUCBEAjS&printMode=true 3/4
11/18/2020 Data Munging.ipynb - Colaboratory
https://colab.research.google.com/drive/1-lZ0Q5iCEUVJkdLT-E4xtjVO4p6Du-Ei?authuser=1#scrollTo=AAL3VUCBEAjS&printMode=true 4/4