我的代码
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:ProgramDataAnaconda3libsite-packagespandascoreframe.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:ProgramDataAnaconda3libsite-packagespandascoreframe.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!
在线求解决办法
最后
以上就是疯狂书包最近收集整理的关于ValueError: DataFrame constructor not properly called!的全部内容,更多相关ValueError:内容请搜索靠谱客的其他文章。
发表评论 取消回复