将pandas用于临床edc/edc项目
edc-pdutils的Python项目详细描述
EDC程序
在EDC中使用熊猫
导出CRF数据,例如:
csv_path='/Users/erikvw/Documents/ambition/export/'date_format='%Y-%m-%d'sep=','classMyDfHandler(CrfDfHandler):visit_tbl='ambition_subject_subjectvisit'exclude_columns=['form_as_json','survival_status','last_alive_date','screening_age_in_years','registration_datetime','subject_type']classMyCsvCrfTablesExporter(CsvCrfTablesExporter):visit_columns=['subject_visit_id']datetime_fields=['randomization_datetime']df_handler_cls=MyDfHandlerapp_label='ambition_subject'export_folder=csv_pathsys.stdout.write('\n')exporter=MyCsvCrfTablesExporter()exporter.to_csv(date_format=date_format,delimiter=sep)
为任何配置了内联的CRF导出内联数据,例如:
classMyDfHandler(CrfDfHandler):visit_tbl='ambition_subject_subjectvisit'exclude_columns=['form_as_json','survival_status','last_alive_date','screening_age_in_years','registration_datetime','subject_type']classMyCsvCrfInlineTablesExporter(CsvCrfInlineTablesExporter):visit_columns=['subject_visit_id']df_handler_cls=MyDfHandlerapp_label='ambition_subject'export_folder=csv_pathexclude_inline_tables=['ambition_subject_radiology_abnormal_results_reason','ambition_subject_radiology_cxr_type']sys.stdout.write('\n')exporter=MyCsvCrfInlineTablesExporter()exporter.to_csv(date_format=date_format,delimiter=sep)
设置
EXPORT_FILENAME_TIMESTAMP_FORMAT:真/假(默认值:假)
默认情况下,当前日期的时间戳作为后缀添加到csv导出文件名中。
默认情况下,将添加格式为%Y%m%d%H%M%S的时间戳。
EXPORT_FILENAME_TIMESTAMP_FORMAT可以设置为空字符串或strftime的有效格式。
如果EXPORT_FILENAME_TIMESTAMP_FORMAT设置为空字符串,“”,则不会添加后缀。
例如:
# default registered_subject_20190203112555.csv # EXPORT_FILENAME_TIMESTAMP_FORMAT = "%Y%m%d" registered_subject_20190203.csv # EXPORT_FILENAME_TIMESTAMP_FORMAT = "" registered_subject.csv