各位!
我正在使用Google Colab来学习更多关于数据科学的知识。当我尝试使用Plotly Express生成图表时,我会收到以下错误:
AttributeError: module 'plotly.express' has no attribute 'Constant'
我试图生成的图表是:
sample = df.rename(columns={"location":"Location","num_sequences_total":"Number of Case"})
fig = px.treemap(sample, path=[px.Constant('Number of Case'),'Location'], values='Number of Case',
hover_data=['Location'])
fig.show()
我导入的库是:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
import statsmodels.api as sm
import pandas_profiling
import plotly.express as px
我尝试使用! pip install --upgrade plotly
升级Plotly,但效果不佳。
你知道我做错了什么吗?
干杯,Marcelo
好吧,既然你没有提供那么多其他信息,有两个想法:
- 升级PIP(PIP本身,而非plotly(并重新安装plotly:
$ python -m pip install --upgrade pip
- 您可以尝试子模块导入:
from plotly import express as px
(未测试(