當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。