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)
 in 
      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!

在线求解决办法

你可能感兴趣的:(python,pandas,开发语言)