Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DAO:
- def get_df(self,file_path,delim):
- df=pd.read_csv(filepath_or_buffer=file_path,delimiter=delim)
- return df
- class Preference(DAO):
- def cleanse_df(self,df):
- df_dropped_nan=df.dropna(axis=0,how='any')[df.item_id!='1']
- df1=df_dropped_nan[df_dropped_nan.user_id.apply(lambda x: x.isnumeric())]
- df2 = df1[df1.item_id.apply(lambda x: x.isnumeric())]
- df2.item_id = df2.item_id.astype(int)
- df2.user_id=df2.user_id.astype(int).copy()
- return df2
- def get_cleansed_df(self,file_path,delim):
- df=DAO.get_df(self,file_path,delim)
- cleansed_df=self.cleanse_df(df)
- return cleansed_df
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement