Loading...
The University of Aizu, Aizu-Wakamatsu, Japan


                         

Converting a dense dataframe into a utility database

Description

A utility database represents a sparse and non-binary representation of items occurring in each row of a dataframe. The steps to convert a dataframe into a utility database is as follows:

  1. Initialize the dense2DB class by passing the following three parameters:
    1. inputDataFrame - the dataframe that needs to converted into a database
    2. thresholdValue - this value will be used to convert a non-binary data frame into a binary database
    3. condition - The condition that needs to employed on the threshold value. Currently, the users can specify the following six constraints: >, >=, <, <=, ==, and !=.
  2. Call ‘createUtility(outputFileName)’ method to store the dataframe as a temporal database.

Sample code

from PAMI.extras.DF2DB import denseDF2DB as pro
import pandas as pd

# Objective: convert the above dataframe into a utility database with items whose value is greater than or equal 1.
db = pro.denseDF2DB(inputDF=pd.DataFrame('mentionDataFrame'), thresholdValue=1, condition='>=')
# Convert and store the dataframe as a utility database file
db.convert2UtilityDatabase(outputFile='/home/userName/utilityDB.txt')
# Getting the fileName of the utility database
print('The output file is saved at ' + db.getFileName())