I am trying to create a graph using Plotly off of a DataFrame as part of a Python course. The DataFrame is created from a local csv file, which is working fine.
cars = pd.read_csv(r'C:\Users\arman\OneDrive\Desktop\mtcars.csv')
cars.columns = ['car_names','mpg','cyl','disp', 'hp', 'drat', 'wt', 'qsec', 'vs', 'am', 'gear', 'carb']
df = cars[['cyl', 'wt','mpg']]
layouts = dict(title = 'Chart From Pandas DataFrame', xaxis= dict(title='x-axis'), yaxis= dict(title='y-axis'))
df.iplot(filename='cf-simple-line-chart', layout= layouts)
When running this, I get the following error:
ValueErrorTraceback (most recent call last)
<ipython-input-9-9d51de7f2e8a> in <module>()
6 cars_select.columns = ['mpg', 'disp', 'hp']
7
----> 8 cars_select.iplot(kind='histogram', filename='multiple-histogram-chart')
C:\Users\arman\AppData\Local\Continuum\anaconda2\lib\site-packages\cufflinks\plotlytools.pyc in _iplot(self, data, layout, filename, sharing, kind, title, xTitle, yTitle, zTitle, theme, colors, colorscale, fill, width, dash, mode, symbol, size, barmode, sortbars, bargap, bargroupgap, bins, histnorm, histfunc, orientation, boxpoints, annotations, keys, bestfit, bestfit_colors, mean, mean_colors, categories, x, y, z, text, gridcolor, zerolinecolor, margin, labels, values, secondary_y, subplots, shape, error_x, error_y, error_type, locations, lon, lat, asFrame, asDates, asFigure, asImage, dimensions, asPlot, asUrl, online, **kwargs)
899 ## Figure defintion
900 figure=Figure()
--> 901 figure['data']=data
902 figure['layout']=layout
903
C:\Users\arman\AppData\Local\Continuum\anaconda2\lib\site-packages\plotly\basedatatypes.pyc in __setitem__(self, prop, value)
234
235 if prop == 'data':
--> 236 self.data = value
237 elif prop == 'layout':
238 self.layout = value
C:\Users\arman\AppData\Local\Continuum\anaconda2\lib\site-packages\plotly\basedatatypes.pyc in __setattr__(self, prop, value)
266 if prop.startswith('_') or hasattr(self, prop):
267 # Let known properties and private properties through
--> 268 super(BaseFigure, self).__setattr__(prop, value)
269 else:
270 # Raise error on unknown public properties
C:\Users\arman\AppData\Local\Continuum\anaconda2\lib\site-packages\plotly\basedatatypes.pyc in data(self, new_data)
439 .format(invalid_uids=invalid_uids))
440
--> 441 raise ValueError(err_msg)
442
443 # ### Check for duplicates in assignment ###
ValueError: The data property of a figure may only be assigned a list or tuple that contains a permutation of a subset of itself
Invalid trace(s) with uid(s): set([None])
Any help would be greatly appreciated.
Edit: I have posted an image of the sample dataset (not sure the best format for posting the csv file; but if it helps, I got this file from the course Python for Data Science Essential Training on Lynda.com) mtcars csv file
I have also tried creating plots with the following DataFrames:
df = pd.DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'
df.scatter_matrix(filename='cufflinks/scatter-matrix', world_readable=True)
and
df = cf.datagen.lines()
df.iplot(kind='scatter', filename='cufflinks/cf-simple-line')
both example DataFrames produce the same error. I'm assuming this may be an issue with Cufflinks. I am currently running the 0.8.2 version.
dataandtrace? Just look in the docs and see how plotly simple skeleton looks like. My thoughts, that you miss to specify data for your xaxis and yxis. You give plot the title - its nice, but plotly as I see have not any data for plot. So am suggest you to set parametertraceand fill him with data. Maybe it can helps