Search code examples
pythongoogle-colaboratory

How to read .arff file in google colab?


Does anyone know how to read an .arff file in Google Colab?

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

raw_data = loadarff('/content/Chronic_Kidney_Disease/chronic_kidney_disease_full.arff')
df_data = pd.DataFrame(raw_data[0])

doesnt work.

    161         else:
    162             raise ValueError("%s value not in %s" % (str(data_str),
--> 163                                                      str(self.values)))
    164 
    165     def __str__(self):

ValueError:  yes value not in ('yes', 'no')

Solution

  • It can be solved using the following code:

    #Import the Libraries
    from scipy.io import arff
    import pandas as pd
    
    #Load the data using "arff.loadarff" then convert it to dataframe
    data = arff.loadarff('spambase.arff')
    df = pd.DataFrame(data[0])