예제 #1
0
 def concat(self, *argv):
     n = 0
     ls = []
     while n < len(argv):
         if isinstance(argv[n], pd.core.series.Series):
             if len(ls) <= 1:
                 ls = argv[n].to_list()
             else:
                 ls0 = argv[n].to_list()
                 ls1 = fn.aplist(ls, ls0)
                 ls = ls1
         n = n + 1
     nc = str(self.mdf.shape[1] + 1)
     df1 = fn.add_col_df(self.mdf, nc)
     df1[nc] = np.array(ls)
     self.mdf = df1
예제 #2
0
 def map_df_dic(self, dic, refcol):
     nc = str(self.mdf.shape[1] + 1)
     df = fn.add_col_df(self.mdf, nc)
     df[nc] = df[refcol].map(dic)
     self.mdf = df
예제 #3
0
 def left(self, sdf, i):
     df1 = fn.add_col_df(self.mdf, 'left_apply')
     df1['left_apply'] = sdf.apply(lambda x: x[0:i])
     self.mdf = df1
예제 #4
0
 def right(self, sdf, i):
     df1 = fn.add_col_df(self.mdf, 'right_apply')
     df1['right_apply'] = sdf.apply(lambda x: x[-i:len(x)])
     self.mdf = df1
예제 #5
0
            n = n + 1
        nc = str(self.mdf.shape[1] + 1)
        df1 = fn.add_col_df(self.mdf, nc)
        df1[nc] = np.array(ls)
        self.mdf = df1

    def conv_datatype(self, colname, typ):
        if typ == 'date':
            self.mdf[colname] = pd.to_datetime(self.mdf[colname],
                                               errors='coerce')
        elif typ == 'int':
            print('x')
        elif typ == 'str':
            self.mdf[colname] = self.mdf[colname].applymap(str)


#ob = vbloop(df1)
#ob.left(df1['Item Type'],5)
#ob.right(df1['Item Type'],3)
#ob.concat(df1['Item Type'],df1['Unit Price'])
print(df0.columns)
df = fn.add_col_df(df0, 'OM')
list_of_cols_as_ref = ['Region', 'Country', 'Item Type']
df['OM'] = df[list_of_cols_as_ref].apply(lambda x: ''.join(map(str, x)),
                                         axis=1)
print(df)
#df[st] = df[list_of_cols_as_ref].apply(lambda x: ''.join(map(str,x)),axis=1)
#print(ob.getdf())
## dL = fn.left (df1, df1['Item Type'], 3)
## dR = fn.right (df1, ddd = fn.right (df1, df1['Item Type'], 3)f1['Item Type'], 3)