概述
我的代码
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: DataFrame constructor not properly called!所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复