Pandas Excelwriter Diverging Color Data Bar

时间:2018-01-30 17:29:54

标签: python python-2.7 pandas pandas.excelwriter

我使用pandas / excelwriter有条件地格式化我的excel文件

但是,我无法创建不同的彩色数据库,就像可以在excel中创建的那样:

enter image description here

我试图设置最小和最大颜色:

worksheet.conditional_format('G2:I80'{'type':'data_bar','min_color':'red','max_color':'green'})

但结果如下:

enter image description here

2 个答案:

答案 0 :(得分:1)

现在可以在XlsxWriter 1.0.4版中使用。请参阅数据库Conditional Formatting Options

对于你的情况,你可以做这样的事情:

worksheet.conditional_format('G2:I80',
                             {'type': 'data_bar',
                              'min_color': 'red',
                              'max_color':'green',
                              'data_bar_2010': True,
                              })

答案 1 :(得分:0)

解决了这个问题: https://github.com/jmcnamara/XlsxWriter/issues/501#issuecomment-378630647

附加了需要替换的worksheet.txt文件 (将文件的扩展名从.txt重命名为.py)

为了使用它,只需添加: 要添加conditional_format,只需使用:

$ tns post-install-cli --log trace
Loading extensions.
execFile: /usr/local/bin/sdkmanager/platform-tools/adb "help"
Error while executing '/usr/local/bin/sdkmanager/platform-tools/adb help'. Error is: spawn ENOTDIR
Exec uname -a 
 stdout: Darwin B52.local 15.6.0 Darwin Kernel Version 15.6.0: Tue Jan  9 20:12:05 PST 2018; root:xnu-3248.73.5~1/RELEASE_X86_64 x86_64

 stderr: 
Exec npm -v 
 stdout: 5.6.0

 stderr: 
Exec node-gyp -v 
 stdout: v3.4.0

 stderr: 
Exec xcodebuild -version 
 stdout:  
 stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Error while executing xcodebuild -version: Command failed: xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Exec gem which xcodeproj 
 stdout:  
 stderr: ERROR:  Can't find ruby library file or shared library xcodeproj

Error while executing gem which xcodeproj: Command failed: gem which xcodeproj
ERROR:  Can't find ruby library file or shared library xcodeproj

Exec pod --version 
 stdout:  
 stderr: /bin/sh: pod: command not found

Error while executing pod --version: Command failed: pod --version
/bin/sh: pod: command not found

Exec null version 
 stdout:  
 stderr: /bin/sh: null: command not found

Error while executing null version: Command failed: null version
/bin/sh: null: command not found

spawn: /usr/local/bin/sdkmanager/tools/emulator "-help"
Error: spawn ENOTDIR
    at _errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:323:11)
    at Object.exports.spawn (child_process.js:502:9)
    at ChildProcess.spawn (/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/common/child-process.js:58:30)
    at Promise (/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/common/child-process.js:66:39)
    at new Promise (<anonymous>)
    at ChildProcess.spawnFromEvent (/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/common/child-process.js:65:16)
    at SysInfo.<anonymous> (/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/common/sys-info-base.js:194:59)
    at Generator.next (<anonymous>)
    at /Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/common/sys-info-base.js:7:71
Initializing analytics statuses.
Analytics statuses:  { TrackFeatureUsage: 'enabled', TrackExceptions: 'enabled' }
spawn: node "/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/services/analytics/analytics-broker-process.js" "/Users/rayman/.nvm/versions/node/v8.9.4/lib/node_modules/nativescript/lib/bootstrap.js"

worksheet.conditional_format("<RANGE>"), { 'guid': "<GUID>", 'type': 'data_bar_bi_directional', 'bar_color': '#8DB4E3', 'min_type':'min', 'max_type':'max' }) - 替换为需要使用双向数据条扩展的一系列单元格 <RANGE> - 将其替换为唯一的GUID