@ -13,7 +13,7 @@ import transport
import json
import pandas as pd
import numpy as np
import cupy as cp
# import cupy as cp
import sys
import os
# from multiprocessing import Process, Queue
@ -62,7 +62,7 @@ class Input :
self . _schema = _args [ ' schema ' ] if ' schema ' in _args else { }
self . df = _args [ ' data ' ]
if ' sql ' not in _args :
# self._initdata(**_args)
self . _initdata ( * * _args )
#
pass
else :
@ -70,12 +70,12 @@ class Input :
self . _map = { } if ' map ' not in _args else _args [ ' map ' ]
# self._metadf = pd.DataFrame(self.df[self._columns].dtypes.values.astype(str)).T #,self._columns]
# self._metadf.columns = self._columns
if ' gpu ' in _args and ' GPU ' in os . environ :
# if 'gpu' in _args and 'GPU' in os.environ :
np = cp
index = int ( _args [ ' gpu ' ] )
np . cuda . Device ( index ) . use ( )
print ( [ ' ..:: GPU ' , index ] )
# np = cp
# index = int(_args['gpu'])
# np.cuda.Device(index).use()
# print(['..:: GPU ',index] )
def _initsql ( self , * * _args ) :
"""
@ -107,6 +107,8 @@ class Input :
row_count = self . df . shape [ 0 ]
cols = None if ' columns ' not in _args else _args [ ' columns ' ]
self . columns = self . df . columns . tolist ( )
self . _io = [ ]
if ' columns ' in _args :
self . _columns = _args [ ' columns ' ]
else :
@ -115,6 +117,8 @@ class Input :
_df = pd . DataFrame ( self . df . apply ( lambda col : col . dropna ( ) . unique ( ) . size ) ) . T
MIN_SPACE_SIZE = 2
self . _columns = cols if cols else _df . apply ( lambda col : None if col [ 0 ] == row_count or col [ 0 ] < MIN_SPACE_SIZE else col . name ) . dropna ( ) . tolist ( )
self . _io = _df . to_dict ( orient = ' records ' )
def _initdata ( self , * * _args ) :
"""
This function will initialize the class with a data - frame and columns of interest ( if any )