1

I'm able to get the data from here in DataFrame. When I'm converting the DataFrame into SFrame using graphlab then this error is showing:

TypeError: A common type cannot be infered from types float, string.

My Code is

import graphlab

import pandas as pd

import numpy as np

import matplotlib.pyplot as pt

from numpy import array

from graphlab import SFrame


user_columns =['No','User id','User Name','Skill','Given Test Name','Given Test ID','Recommend Test','Recommend Test ID','Time Start','Time End','Score','Max Score']

data=pd.read_table('http://tech4partner.com.cp-in-5.webhostbox.net/recommend_test.php', sep='^',header=None,names = user_columns)

df2 = data.ix[2:]

df3=df2.reset_index()

df4=df3.drop('index', axis=1)

df5=df4.drop(df4.index[len(df4)-1])

df5=df5.reset_index(1,[len(df5)-1])

df7 = df5.reset_index()

df8=df7.drop('index', axis=1)

df9=df8.head(len(df8))

df9.index = np.arange(1, len(df9) + 1)

df9=df9.head(50)

df9

Data is showing in DataFrame at this line..When I convert the DataFrame into Sframe, It gives error.

DataFrame converts into SFrame using .Sframe() method

t_data = graphlab.SFrame(df9)

t_data

and according to me Data is in well format or may be not. And also I tried two solution but it didn't work for me.

1) I checked every column but no column has different data type.

2) I converted every column in a specific data type using

df.column_name.astype(str) and df['column_name']= df[coulmn_name].astype(str)

but it didn't work any more.

TypeError                                 Traceback (most recent call last)
<ipython-input-11-c852cd1e7f45> in <module>()
----> 1 t_data = graphlab.SFrame(df9)
      2 t_data
      3 
C:\Anaconda2\lib\site-packages\graphlab\data_structures\sframe.pyc in __init__(self, data, format, _proxy)
    951                     pass
    952                 else:
--> 953                     raise ValueError('Unknown input type: ' + format)
    954 
    955         sframe_size = -1
C:\Anaconda2\lib\site-packages\graphlab\cython\context.pyc in __exit__(self, exc_type, exc_value, traceback)
     47             if not self.show_cython_trace:
     48                 # To hide cython trace, we re-raise from here
---> 49                 raise exc_type(exc_value)
     50             else:
     51                 # To show the full trace, we do nothing and let exception propagate
**TypeError: A common type cannot be infered from types float, string.**

How can I convert this DataFrame into SFrame?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jun 23 '17 at 13:06
  • Thanks for commenting, If you got feel i wrote something wrong "Urgent" and "Asap" ,which is not acceptable then Sorry. I don't mind you can downvote my question . – ATUL VARSHNEY Jun 26 '17 at 05:26
  • Let me tell you one thing I'm using Jupyter in Anaconda. I've already made a script in Jupyter where DataFrame is easily converted into SFrame without any troubling.Thanx Halfer – ATUL VARSHNEY Jun 26 '17 at 05:30

1 Answers1

0

try this syntax for conversion:

df['column_name'] = df['column_name'].astype(float)
df['column_name'] = df['column_name'].astype(str)
AaronDT
  • 3,940
  • 8
  • 31
  • 71
  • I also used this syntax .. it's not working for me .. and now i edited my question and share completed code as you can see.... – ATUL VARSHNEY Jun 24 '17 at 10:34