最近碰到读取一个目录中所有的pickle文件的任务,顺便记录一下。
import os
import pandas as pd
from collections import defaultdict, Counter
import numpy as np
import sys
sys.path.append(r'D:\PycharmProjects\A\B')
from C import *
import dill as pickle
for filename in os.listdir('./test'):
abs_path = os.path.abspath('./test')
complete_filename = os.path.join(abs_path,filename)
str_filename = filename.split('_')
iteration = str_filename[0]
df_final_Rules = LoadVariablestoPickleFile(complete_filename)
columns_list = df_final_Rules.columns.values.tolist()
参考 【1】https://blog.csdn.net/l641208111/article/details/101116809
|