取消合并或填写pandas groupby dataframe中的列

时间:2015-07-17 23:59:25

标签: python pandas

我有一个数据框,当在终端中打印或发送到excel文件时,如下所示。

+-----------------------------------------------------------------------------------------------------------+
| 112      Martin Messenger Bag                  MRKT-15-0004  Accessories Watch by Featured Host       NaN |
| 262      Fauna Pouch Kitten                    AREA-15-0050  Accessories Watch by Featured Host       NaN |
| 263      Key Cable                             NATI-15-0005  Gadgets     Featured                     NaN |
|                                                                          Gadgets                      NaN |
|                                                                          Summer Staples               NaN |
| 110      Winter Remedy Pack                    ECOA-15-0002  Home Goods  Home Goods                   NaN |
| 109      Travel Set                            ECOA-15-0001  Beauty      Featured                     NaN |
| 274      Ideal Notebook for iPhone             MOLLA-15-0014 Gadgets     Watch by Featured Host       NaN |
+-----------------------------------------------------------------------------------------------------------+

当前发送到excel的项目263合并了单元格。填写两个合并行的数据的最佳方法是什么?这是pandas.DataFrame.reset_index的情况吗?

编辑:我正在使用XlsxWriter库编写excel文件

1 个答案:

答案 0 :(得分:1)

var arr = [ {id: 43}, {id: 64}, {id: 12} ] function findNext(arr, el) { var index = arr.indexOf(el); return index > 0 ? arr[(index + 1) % arr.length] : index; } alert(JSON.stringify(findNext(arr, arr[2]))); 是一个默认为merge_cells的选项。尝试将其设置为True

False