# -*- coding: utf-8 -*- # @Time : 2022/11/1 14:26 # @Author : ZAOXG # @File : file_write.py import pandas as pd __all__ = [ 'write_data' ] file_type_operation = { 'csv': 'to_csv', 'xlsx': 'to_excel', 'xls': 'to_excel' } def write_data(data, file, index=True, **kwargs) -> pd.DataFrame: file_type = file.rsplit('.')[-1] temp: pd.DataFrame = getattr(data, file_type_operation[file_type])(file, index=index, **kwargs) return temp