예제 #1
0
from frovedis.dataframe.df import FrovedisDataframe

FrovedisServer.initialize("mpirun -np 2 {}".format(
    os.environ['FROVEDIS_SERVER']))

data = {
    'A': [10, 12, 13, 15],
    'B': [10.23, 12.20, 34.90, 100.12],
    'C': ['male', 'female', 'female', 'male'],
}
pdf = pd.DataFrame(data)
df = FrovedisDataframe(pdf)
print(pdf)
print

row_mat = df.to_frovedis_rowmajor_matrix(['A', 'B'], dtype=np.float64)
print(row_mat.to_numpy_matrix())
print

#col_mat = df.to_frovedis_colmajor_matrix(['A', 'B'], dtype=np.float64)
#print (col_mat.to_numpy_matrix())

crs_mat, info = df.to_frovedis_crs_matrix(['A', 'B', 'C'], ['C'],
                                          need_info=True)
crs_mat.debug_print()
print

data2 = {
    'A': [12, 13],
    'B': [34.56, 78.9],
    'C': ['male', 'male'],
예제 #2
0
    'one': [10, 12, 13, 15],
    'two': [10.23, 12.20, 34.90, 100.12],
    'three': ['F', 'F', 'D', 'A'],
    'four': [0, 0, 1, 2]
}
pdf = pd.DataFrame(data)
print(pdf.describe())
print("\n")
df = FrovedisDataframe(pdf)
print(df.describe())
print("\n")  # prints count, mean, std, sum, min, max

# matrix conversion demo
df.show()

row_mat = df.to_frovedis_rowmajor_matrix(['one', 'two'], dtype=np.float64)
row_mat.debug_print()

col_mat = df.to_frovedis_colmajor_matrix(['one',
                                          'two'])  # default dtype = float32
col_mat.debug_print()

crs_mat, info = df.to_frovedis_crs_matrix(
    ['one', 'two', 'four'], ['four'],
    need_info=True)  # default dtype = float32
crs_mat.debug_print()

crs_mat2 = df.to_frovedis_crs_matrix_using_info(info)
crs_mat2.debug_print()

df.release()