Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 中值为0的xlsxwriter条件格式图标\未显示正确的箭头_Python_Python 3.x_Xlsxwriter - Fatal编程技术网

Python 中值为0的xlsxwriter条件格式图标\未显示正确的箭头

Python 中值为0的xlsxwriter条件格式图标\未显示正确的箭头,python,python-3.x,xlsxwriter,Python,Python 3.x,Xlsxwriter,问题是: 我想使用xlsx将条件格式图标\u集应用于列,但无法获得正确值的正确箭头 这是我想要的输出: writer.sheets[sheet].conditional_format('J54:K200', {'type': 'icon_set', 'icon_style': '3_arrows',

问题是: 我想使用xlsx将条件格式图标\u集应用于列,但无法获得正确值的正确箭头

这是我想要的输出:

writer.sheets[sheet].conditional_format('J54:K200', {'type': 'icon_set',
                                                         'icon_style': '3_arrows',

                                                         'icons': [
                  {'criteria': '>=', 'type': 'number', 'value': 1},
                  {'criteria': '>=', 'type': 'number', 'value': 0},
                  {'criteria': '<', 'type': 'number', 'value': -1}

                                                         ]}
                                            )

这是我当前的输出:

writer.sheets[sheet].conditional_format('J54:K200', {'type': 'icon_set',
                                                         'icon_style': '3_arrows',

                                                         'icons': [
                  {'criteria': '>=', 'type': 'number', 'value': 1},
                  {'criteria': '>=', 'type': 'number', 'value': 0},
                  {'criteria': '<', 'type': 'number', 'value': -1}

                                                         ]}
                                            )

这是我的代码:

writer.sheets[sheet].conditional_format('J54:K200', {'type': 'icon_set',
                                                         'icon_style': '3_arrows',

                                                         'icons': [
                  {'criteria': '>=', 'type': 'number', 'value': 1},
                  {'criteria': '>=', 'type': 'number', 'value': 0},
                  {'criteria': '<', 'type': 'number', 'value': -1}

                                                         ]}
                                            )
writer.sheets[sheet].conditional_格式('J54:K200',{'type':'icon_set',
“图标样式”:“3个箭头”,
“图标”:[
{'criteria':'>=','type':'number','value':1},
{'criteria':'>=','type':'number','value':0},

{'criteria':'如果从代码中删除
{'criteria':'>=','type':'number','value':0},
,它应该可以正常工作。下面我有一个可复制的示例,其中包含预期的输出

import pandas as pd
import numpy as np

#Creating a sample dataframe for example demonstration
df = pd.DataFrame({'col1': [0, -1, 10, -2], 'col2': [-11, 0, -3, 1]})


writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1', index=False)

writer.sheets['Sheet1'].conditional_format('A2:B5', {'type': 'icon_set',
                                                         'icon_style': '3_arrows',
                                                         'icons': [
                  {'criteria': '>=', 'type': 'number', 'value': 0.001},
                  {'criteria': '<=', 'type': 'number', 'value': -0.001}
                                                         ]}
                                            )


writer.save()
将熊猫作为pd导入
将numpy作为np导入
#创建示例数据框以进行示例演示
df=pd.DataFrame({'col1':[0,-1,10,-2],'col2':[-11,0,-3,1]})
writer=pd.ExcelWriter('test.xlsx',engine='xlsxwriter')
df.to_excel(编写器,工作表名称='Sheet1',索引=False)
writer.sheets['Sheet1'].conditional_格式('A2:B5',{'type':'icon_set',
“图标样式”:“3个箭头”,
“图标”:[
{'criteria':'>=','type':'number','value':0.001},

{'criteria':'这就像一个符咒。对于未来的用户来说,在撰写此评论时:文档在这种情况下是误导性的:说“icons-criteria参数应该是>=或=”。我理解为criteria参数不能是