本文整理汇总了Python中preprocessor.Preprocessor.to_csv方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.to_csv方法的具体用法?Python Preprocessor.to_csv怎么用?Python Preprocessor.to_csv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preprocessor.Preprocessor
的用法示例。
在下文中一共展示了Preprocessor.to_csv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Preprocessor
# 需要导入模块: from preprocessor import Preprocessor [as 别名]
# 或者: from preprocessor.Preprocessor import to_csv [as 别名]
sensormerge = []
othermerge = []
summary = {}
for target in to_preprocess:
target_path = os.path.join(extract_path, target)
columns = spec[target][cols_key].split(',')
renames = spec[target][rename_key] if rename_key in spec[target].keys() else None
# Preprocess and write out a standalone file for the data source
preproced = Preprocessor(target_path, columns, renames).run()
if to_merge:
if set(sensor_keys) < set(columns):
sensormerge.append(preproced)
else:
othermerge.append(preproced)
preproced.to_csv(os.path.join(out_path, target + '.pprc'), header=preproced.columns, index=False)
# Generate summary of preprocessed data
summary[target] = Summarizer(preproced).get_full_report()
# Note missing files and write out a standalone summary file
summary['missing'] = [f for f in target_files if f not in to_preprocess]
with open(os.path.join(out_path, 'summary.json'), 'w') as sumfile:
json.dump(summary, sumfile, sort_keys=True, indent=4)
# Merge sensors together first, then everything else, then write it out
if to_merge:
merged = reduce(lambda x,y: x.merge(y, how='outer', on=sensor_keys, sort=False), sensormerge)
merged = reduce(lambda x,y: x.merge(y, how='outer', on=all_keys, sort=True), othermerge, merged)
merged.to_csv(os.path.join(out_path, 'merged.pprc'), header=merged.columns, index=False)