Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Pandas DataFrame into Pandas ML ModelFrame?

I would like to repeat these example_1 example_2 with my dataset.

import pandas_ml as pdml

df = pdml.ModelFrame({'A': [1, 2, 3], 'B': [2, 3, 4],
                   'C': [3, 4, 5]}, index=['a', 'b', 'c'])
df
   A  B  C
a  1  2  3
b  2  3  4
c  3  4  5

But, the issue is I have my data set in a csv file.

x_test = pd.read_csv("x_test.csv",sep=';',header=None)

I've tried to convert pandas data frame to dict, but it didn't work.

So, the question is there a way for converting the pandas dataframe into Pandas-Ml ModelFrame?

like image 826
Vadim Avatar asked Oct 17 '22 13:10

Vadim


1 Answers

I think you need DataFrame.to_dict with parameter orient:

x_test = pd.read_csv("x_test.csv",sep=';',header=None)
df = pdml.ModelFrame(x_test.to_dict(orient='list'))
like image 136
jezrael Avatar answered Oct 27 '22 07:10

jezrael