示例#1
0
 def __convert_to_df(self, data):
     """
     NAME: __convert_to_df
     """
     tid = []
     item = []
     cur_id = 0
     for trans in data:  # for each transaction in data
         for trans_it in trans:  # for each item in each transaction
             tid.append(cur_id)
             item.append(trans_it)
         cur_id = cur_id + 1
     tid = np.asarray(tid, dtype=np.int32)
     item = np.asarray(item, dtype=np.int32)
     df_t = pd.DataFrame({'trans_id': tid, 'item': item}, \
             columns=['trans_id', 'item'])
     return FrovedisDataframe(df_t)
示例#2
0
import os
import numpy as np
import pandas as pd
from frovedis.exrpc.server import FrovedisServer
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
示例#3
0
FrovedisServer.initialize(argvs[1])

peopleDF = {
    'Ename': ['Michael', 'Andy', 'Tanaka', 'Raul', 'Yuta'],
    'Age': [29, 30, 27, 19, 31],
    'Country': ['USA', 'England', 'Japan', 'France', 'Japan']
}

countryDF = {
    'Ccode': [1, 2, 3, 4],
    'Country': ['USA', 'England', 'Japan', 'France']
}

pdf1 = pd.DataFrame(peopleDF)
pdf2 = pd.DataFrame(countryDF)
fdf1 = FrovedisDataframe(pdf1)
fdf2 = FrovedisDataframe(pdf2)

# displaying created frovedis dataframes
fdf1.show()
fdf2.show()

# select demo
fdf1["Ename"].show()  # single column
fdf1[["Ename", "Age"]].show()  # multiple column

# filter demo
fdf1[fdf1.Age > 19].show()
fdf1[fdf1.Age > 19 and fdf1.Country == 'Japan'].show()

# sort demo
示例#4
0
FrovedisServer.initialize(argvs[1])

peopleDF = {
    'Ename': ['Michael', 'Andy', 'Tanaka', 'Raul', 'Yuta'],
    'Age': [29, 30, 27, 19, 31],
    'Country': ['USA', 'England', 'Japan', 'France', 'Japan']
}

countryDF = {
    'Ccode': [1, 2, 3, 4],
    'Country': ['USA', 'England', 'Japan', 'France']
}

pdf1 = pd.DataFrame(peopleDF)
pdf2 = pd.DataFrame(countryDF)
fdf1 = FrovedisDataframe(pdf1)
fdf2 = FrovedisDataframe(pdf2)

# displaying created frovedis dataframes
fdf1.show()
fdf2.show()

# select demo
fdf1["Ename"].show()  # single column
fdf1[["Ename", "Age"]].show()  # multiple column

# filter demo
fdf1[fdf1.Age > 19].show()
fdf1[fdf1.Age > 19 and fdf1.Country == 'Japan'].show()

# sort demo
示例#5
0
FrovedisServer.initialize("mpirun -np 2 {}".format(os.environ['FROVEDIS_SERVER']))

peopleDF = {
            'Ename' : ['Michael', 'Andy', 'Tanaka', 'Raul', 'Yuta'], 
            'Age' : [29, 30, 27, 19, 31],
            'Country' : ['USA', 'England', 'Japan', 'France', 'Japan']
           }

countryDF = {
             'Ccode' : [1, 2, 3, 4],
             'Country' : ['USA', 'England', 'Japan', 'France']
            }

pdf1 = pd.DataFrame(peopleDF)
pdf2 = pd.DataFrame(countryDF)
fdf1 = FrovedisDataframe(pdf1)
fdf2 = FrovedisDataframe(pdf2)

# display created frovedis dataframes
print ("* print Frovedis DataFrame")
fdf1.show()
fdf2.show()

# select demo
print ("* select Ename and Age")
fdf1[["Ename","Age"]].show()

# filter demo
print ("* filter by Age > 19 and Contry == 'Japan'")
fdf1[fdf1.Age > 19 and fdf1.Country == 'Japan'].show()