Python之pandas封装get、set方法

import pandas as pd

def get_arr_from_xls(xls_path):
    df = pd.read_excel(xls_path)
    arr = df.values.tolist()
    return arr

def set_xls_by_xls(arr, xls_path):
    df = pd.DataFrame(arr)
    df.to_excel(xls_path)
    return xls_path

 

use:

if __name__ == '__main__':
    arr = pd.get_arr_from_xls("test.xlsx")
    pd.set_xls_by_xls(arr, "test2.xlsx")
    print("done")

  

 

done

 

 

 

 

 

  

posted @ 2025-04-14 10:45  liskov_design  阅读(12)  评论(0)    收藏  举报