Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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 melt函数将我的id_变量设置为0值?_Python_Pandas_Transpose - Fatal编程技术网

为什么Python melt函数将我的id_变量设置为0值?

为什么Python melt函数将我的id_变量设置为0值?,python,pandas,transpose,Python,Pandas,Transpose,这是我用Pandas groupby创建的数据帧 #Consistent Data Entry by Lab Location: Find gaps in the data dfGaps = data.groupby(data['Status'])[['Model Number', 'SKU type', 'Equipment Type', 'SSC Roster', 'Program']].apply(lambda x: x.isnull().sum()) dfGaps.T[dfGaps.a

这是我用Pandas groupby创建的数据帧

#Consistent Data Entry by Lab Location: Find gaps in the data
dfGaps = data.groupby(data['Status'])[['Model Number',
'SKU type',
'Equipment Type',
'SSC Roster',
'Program']].apply(lambda x: x.isnull().sum())

dfGaps.T[dfGaps.any()].T.reset_index()

print(dfGaps)
我得到了这个结果

             |Model Number  |SKU type  |Equipment Type  |SSC Roster  |Program | 
             | ------------ | -------- | -------------- | ---------- | ------ |
Status       |              |          |                |            |        |  
Canceled     |           0  |      73  |             0  |         0  |      0 |  
Development  |           0  |       7  |             3  |         0  |      1 |  
EoL          |           0  |      74  |             0  |         0  |      0 |  
Production   |           0  |     298  |             0  |         0  |      2 |
那么,当我尝试使用melt函数时,为什么会得到零呢

dfMelt = dfGaps.melt(id_vars= 'Status', value_name='MissingItemCnt', var_name='FieldName')#.reset_index()

print(dfMelt)
为什么我得到这个输出?为什么我在状态列中得到的是0而不是状态名称

[4 rows x 23 columns]
    Status     FieldName  MissingItemCnt
0        0  Model Number               0
1        0  Model Number               0
2        0  Model Number               0
3        0  Model Number               0
4        0      SKU type              73