小编Cal*_*ett的帖子

Python中的Plotly动画滑块

我试图在Jupyter笔记本中重新创建这个例子.

https://plot.ly/python/gapminder-example/

但是收到了这个错误:

PlotlyDictKeyError: 'slider' is not allowed in 'layout'

Path To Error: ['layout']['slider']

Valid attributes for 'layout' at path ['layout'] under parents ['figure']:

    ['angularaxis', 'annotations', 'autosize', 'bargap', 'bargroupgap',
    'barmode', 'barnorm', 'boxgap', 'boxgroupgap', 'boxmode', 'calendar',
    'direction', 'dragmode', 'font', 'geo', 'height', 'hiddenlabels',
    'hiddenlabelssrc', 'hidesources', 'hoverlabel', 'hovermode', 'images',
    'legend', 'mapbox', 'margin', 'orientation', 'paper_bgcolor',
    'plot_bgcolor', 'radialaxis', 'scene', 'separators', 'shapes',
    'showlegend', 'sliders', 'smith', 'ternary', 'title', 'titlefont',
    'updatemenus', 'width', 'xaxis', 'yaxis']

Run `<layout-object>.help('attribute')` on any of the above.
'<layout-object>' is the object at ['layout']
Run Code Online (Sandbox Code Playgroud)

动画运行时没有将滑块dict添加到布局中,滑块可见且可操作,但不会更改图形.当我移动滑块时,它会在控制台中产生以下错误: …

python animation data-visualization slider plotly

19
推荐指数
1
解决办法
2411
查看次数

pyodbc :(“参数必须在列表,元组或行中”,“ HY000”)和NumPy数据

我正在尝试使用Python 3通过pyodbc将元组列表插入MS SQL表。

conn_string = (('DRIVER=FreeTDS;'
                'SERVER={};'
                'PORT=1433;'
                'DATABASE={};'
                'UID={};'
                'PWD={};'
                'TDS_Version=8.0;')
               .format(server, db, user, pwd))
sql = """
insert into Table1(field1, field2, field3) values (?, ?, ?)
"""

cursor.executemany(sql, [('1175B57E-7A10-4BAC-B22E-457C8266C0F2', '1D111FA5-A65D-4F77-A3AB-78B80BAF0C0B', 2),
 ('C60FA1C9-7656-4EBF-A577-44CBF0C641F4', '365FB706-9F7F-4ED4-AB88-927AE1F762A6', 1),
 ('2DF071CE-ABDF-4119-9573-2B0CA2B99C9C', '590E266D-810C-4DC2-BA5A-BAC05A9982C4', 0),
 ('EB794EF9-5FF4-49D3-B81E-F14F69C09306', '1D6E0C95-DF96-45D5-B8F3-211D825A160F', 0),
 ('EB794EF9-5FF4-49D3-B81E-F14F69C09306', '17D2EC66-845F-495D-9020-91E144B2E595', 0),
 ('EB794EF9-5FF4-49D3-B81E-F14F69C09306', '3A694B33-39F4-4F5B-899B-9B27810E4D82', 1),
 ('2DF071CE-ABDF-4119-9573-2B0CA2B99C9C', '4EE1D6F4-4A1E-4316-93D5-2AE1F461A193', 0),
 ('410DE087-1ADF-4EEA-BCE6-D7A1124E2A51', '17D2EC66-845F-495D-9020-91E144B2E595', 0),
 ('C60FA1C9-7656-4EBF-A577-44CBF0C641F4', '250256D4-4A3A-48E0-BCBA-7CD89011D81F', 1),
 ('2DF071CE-ABDF-4119-9573-2B0CA2B99C9C', '4D363718-FE0C-4257-8E4C-5C9A024BAEFF', 0)])
Run Code Online (Sandbox Code Playgroud)

但这不是:

params = list(row for row in data_table.round(0).head(10).to_records(index=False))

cursor.executemany(sql, params)
Run Code Online (Sandbox Code Playgroud)

产生此错误:

('Params must be in a list, tuple, or Row', …
Run Code Online (Sandbox Code Playgroud)

python numpy pyodbc pandas

2
推荐指数
1
解决办法
3590
查看次数

标签 统计

python ×2

animation ×1

data-visualization ×1

numpy ×1

pandas ×1

plotly ×1

pyodbc ×1

slider ×1