我在使用plotlyexpress生成3d散点图时遇到问题。
这是我的数据框:
这是我的代码:
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)
这是我的错误:
ValueError: Value of 'x' is not the name of a column in 'data_frame'. Expected one of ['Samples;FSI;GSI;OSR'] but received: OSR
问题是分号吗?
此错误表明DataFrame未被正确识别,解决方法是读取csv时必须指定正确的分隔符,
df = pd.read_csv('/Users/alissanicolet./Desktop/QGIS_Thesis/pythongraph.csv', delimiter = ';')
其余代码似乎是正确的。