python - UnicodeEncodeError:“latin-1”编解码器无法对位置 0-9 中的字符进行编码:序数不在范围内(256)
问题描述
我正在尝试在 Python 中使用 plotly 从时间序列制作交互式图表,但出现此错误:UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-9: ordinal not in range(256)
这是我的代码:
from pathlib import Path
import plotly
import chart_studio
chart_studio.tools.set_credentials_file(username='****',
api_key='*****')
import chart_studio.plotly as py
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
def parser2(x):
try:
return datetime.strptime( x, '%Y-%m-%d %H:%M:%S')#
except:
return 0
filename = r'AT_2018_10last.csv'
datafolder = Path('C:\HiWi Rodriguez\AT 2018\Last Value')
pathfile = datafolder / filename
ts = read_csv(pathfile, header=0, parse_dates=[0], index_col=0 , date_parser=parser2)#, dtype = dtypes)
ts.columns = ['A']
ts.plot()
AT = go.Scatter(x=ts.index, y=ts.A)
layout = go.Layout(title='Ambient Temperature', xaxis=dict(title='Date'),
yaxis=dict(title='[°C]'))
fig = go.Figure(data=AT, layout=layout)
py.iplot(fig, sharing='public')
解决方案
推荐阅读
- javascript - Individual column searching filter for js sourced data using DataTable.js
- magento2 - 我们找不到符合选择的产品。megento 2中的错误
- java - 如何以正确的顺序将 LinkedHasMap 值转换为 ArrayList/Array?
- php - 如何使用php在表格中显示低于同一日期的出勤率?
- mysql - 从 mysql 到 HDFS 或 Hive 表的数据实时更新(CDC 方法)
- list - 如何使特定列表值(tcl)
- python - 使用 sed、awk、perl 等删除 N 个匹配模式
- php - 如何创建用于连接数据库的索引文件
- .htaccess - 使用 htaccess 在每个 URL 的末尾添加“?XDEBUG_PROFILE=on”
- javascript - 如何通过单击父