0

I'm having a problem producing a 3d scatter plot with plotly express.

Here is my data frame:

df

Here is my code:

df = pd.read_csv('/Users/alissanicolet./Desktop/QGIS_Thesis/pythongraph.csv')
print(df)

fig = px.scatter_3d(
    data_frame=df,
    x='OSR',
    y='GSI',
    z='FSI',
    color="Samples",
    color_discrete_sequence=['magenta','green','blue'],
    template='ggplot2',
    title='Spacematrix of Sample Areas',
    hover_name='Samples',
    height=700,
    
)

pio.show(fig)

Here is my error:

ValueError: Value of 'x' is not the name of a column in 'data_frame'. Expected one of ['Samples;FSI;GSI;OSR'] but received: OSR

Is it the semi-colons that are the problem?

Derek O
  • 16,770
  • 4
  • 24
  • 43
miso
  • 11
  • 2
  • I think you're on the right track? It looks like it's expecting 'Samples;FSI;GSI;OSR' rather than splitting them out into column names. – Alexander Jordan Jun 17 '22 at 13:25
  • 2
    Hey! I solved it by doing an excel instead. Now it is properly split into columns :)))) – miso Jun 17 '22 at 13:32
  • 1
    The heading row has ":" instead of ";". Once file is corrected, read_csv should have `sep=';'`, as default is ','. Post that it will work. Just tried it – Redox Jun 17 '22 at 13:43

0 Answers0