11import pandas as pd
22import numpy as np
3- import seaborn as sn
3+ import seaborn as sns
4+ import matplotlib .pyplot as plt
45
56id_no = ["P001" ,"P002" ,"P003" ,"P004" ,"P005" ,"P006" ,"P007" ,"P008" ,"P009" ,"P010" ,"P011" ]
67gender = ["M" ,"F" ,"M" ,"F" ,"M" ,"F" ,"M" ,"F" ,"M" ,"F" ,"M" ]
699700# where()
700701# interpolate()
701702
702- print (df )
703+ # print(df)
703704
704705########## a.Filling with a specific value :
705706
11371138# 9 P010 F FT DS NaN 7.0 125.0 FT 125.0
11381139# 10 P011 M PT AWS 6.0 9.0 59.0 PT 59.0
11391140
1141+ ######### Filling with interpolation ######################
1142+ flights = sns .load_dataset ('flights' )
1143+ # print(flights)
1144+ # year month passengers
1145+ # 0 1949 Jan 112
1146+ # 1 1949 Feb 118
1147+ # 2 1949 Mar 132
1148+ # 3 1949 Apr 129
1149+ # 4 1949 May 121
1150+ # .. ... ... ...
1151+ # 139 1960 Aug 606
1152+ # 140 1960 Sep 508
1153+ # 141 1960 Oct 461
1154+ # 142 1960 Nov 390
1155+ # 143 1960 Dec 432
1156+ #
1157+ # [144 rows x 3 columns]
11401158
1141- # ------------------------------------------------------------
1142- # ------------------------------------------------------------
1143- # ------------------------------------------------------------
1144- # ------------------------------------------------------------
1145- # ------------------------------------------------------------
1146- # ------------------------------------------------------------
1147- # ------------------------------------------------------------
1148- # ------------------------------------------------------------
1149- # ------------------------------------------------------------
1150- # ------------------------------------------------------------
1151- # ------------------------------------------------------------
1152- # ------------------------------------------------------------
1153- # ------------------------------------------------------------
1154- # ------------------------------------------------------------
1155- # ------------------------------------------------------------
1156- # ------------------------------------------------------------
1157- # ------------------------------------------------------------
1158- # ------------------------------------------------------------
1159- # ------------------------------------------------------------
1160- # ------------------------------------------------------------
1161- # ------------------------------------------------------------
1162- # ------------------------------------------------------------
1163- # ------------------------------------------------------------
1164- # ------------------------------------------------------------
1165- # ------------------------------------------------------------
1166- # ------------------------------------------------------------
1159+ # print(flights.isnull().sum())
1160+ # year 0
1161+ # month 0
1162+ # passengers 0
1163+ # dtype: int64
1164+
1165+ flights ['passengers' ].plot ()
1166+ # plt.show()
1167+
1168+ flights_copy = flights .copy ()
1169+ flights_copy .loc [np .random .randint (1 , 144 , 20 ), 'passengers' ]= None
1170+ # print(flights_copy.isnull().sum())
1171+ # year 0
1172+ # month 0
1173+ # passengers 20
1174+ # dtype: int64
1175+
1176+ flights_copy ['passengers' ].plot ()
1177+ # plt.show()
1178+
1179+ flights_copy ['passengers' ].interpolate ().plot ()
1180+ # plt.show()
1181+
1182+ flights ['passengers' ].plot ()
1183+ # plt.show()
1184+
1185+ # ------------------------------------------------------------
0 commit comments