Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert the arff object loaded from a .arff file into a dataframe format?

I was able to load the .arff file using the following commands. But I was not able to extract the data from the object and convert the object into a dataframe format. I need this to do apply machine learning algorithms on this dataframe.

Command:-

import arff
dataset = pd.DataFrame(arff.load(open('Training Dataset.arff')))
print(dataset)

Please help me to convert the data from here into a dataframe.

like image 428
Thomas John Avatar asked Sep 25 '17 08:09

Thomas John


Video Answer


1 Answers

import numpy as np
import pandas as pd
from scipy.io.arff import loadarff 

raw_data = loadarff('Training Dataset.arff')
df_data = pd.DataFrame(raw_data[0])

Try this. Hope it helps

like image 173
Sagar Dawda Avatar answered Oct 22 '22 01:10

Sagar Dawda