ValueError: DataFrame constructor not properly called!

我的代码

import os
import pandas as pd

basePath='E:\\shiyan'
folders=os.listdir(basePath)
print(folders)

df = pd.DataFrame()
for folder in folders:
    files = os.listdir(os.path.join(basePath,folder))
    print(files)
    for file in files:
        if file.endswith('image.nrrd'):
            imageFile=os.path.join(basePath,folder,file)
        if file.endswith('lable.nrrd'):
            maskFile=os.path.join(basePath,folder,file)
        print(imageFile,maskFile)

extractor=featureextractor.RadiomicsFeatureExtractor()
        featureVector=extractor.execute(imageFile,maskFile)
        df_new = pd.DataFrame.from_dict(featureVector.values()).T
        df_new.columns=featureVector.keys()
        df=pd.concat([df,df_new])
df.to_excel(os.path.join(basePath,'results.xlsx'))

运行时返回错误

ValueError                                Traceback (most recent call last)
<ipython-input-95-0eea3c746f07> in <module>
      1 extractor=featureextractor.RadiomicsFeatureExtractor()
      2 featureVector=extractor.execute(imageFile,maskFile)
----> 3 df_new = pd.DataFrame.from_dict(featureVector.values()).T
      4 df_new.columns=featureVector.keys()
      5 df=pd.concat([df,df_new])

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in from_dict(cls, data, orient, dtype, columns)
    983             raise ValueError('only recognize index or columns for orient')
    984 
--> 985         return cls(data, index=index, columns=columns, dtype=dtype)
    986 
    987     def to_dict(self, orient='dict', into=dict):

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy)
    420                                          dtype=values.dtype, copy=False)
    421             else:
--> 422                 raise ValueError('DataFrame constructor not properly called!')
    423 
    424         NDFrame.__init__(self, mgr, fastpath=True)

ValueError: DataFrame constructor not properly called!

在线求解决办法

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值