【发布时间】:2019-06-13 17:32:53
【问题描述】:
我想设置一个包含“多个数据帧”的更新泡菜文件
因此,我有一个列表 db_container,其中包含其他列表(“数据框类别”:alert1, alert2, alert3),其中包括实际的数据框(例如,alert1 有 n 个不同的数据框,但它们始终具有相同的列名字)
现在,我在使用来自 db_container 的新数据扩展我的初始 db 时遇到问题
我的问题是在数据帧级别扩展 db。
在我运行我的代码后,db 有 6 个项目,而不是最初的 3 个(alert1、alert2、alert3)。
db 和 db_container 应该始终具有初始的 3 个“数据框类别”。
有什么建议吗?
def pickle_me():
# Bind Lists of DataFrames into one Object
db_container = [alert1, alert2, alert3]
# if a db/pickle already exists then open old one and append with new input
if os.path.exists(base_path+pickle_db):
with open(base_path+pickle_db,'rb') as rfp:
db = pickle.load(rfp)
db.append(db_container) #-> After this code section db has 6 lists
pickle.dump(db, open(base_path + pickle_db, 'wb'))
# If no db exists then create one.
else:
pickle.dump(db_container, open(base_path + pickle_db, 'wb'))
谢谢。
【问题讨论】: