当前位置: 首页>>代码示例>>Python>>正文


Python Preprocessor.to_csv方法代码示例

本文整理汇总了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)
开发者ID:safi-manar,项目名称:SensorInference,代码行数:32,代码来源:preprocess.py


注:本文中的preprocessor.Preprocessor.to_csv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。