简体   繁体   English

如何在python 2.7中通过pickle存储多个文件(两个列表和一个df)

[英]How to store multiple files (two list and a df) by pickle in python 2.7

I'm new using python programming. 我是使用python编程的新手。 I have developed a program, and i have created 2 list (a and b) and also a dataframe using pandas. 我开发了一个程序,并创建了2个列表(a和b)以及一个使用熊猫的数据框。 I wanted to save all them together by using pickle, so that, then i can load them in another script that i want to create. 我想通过使用pickle将它们全部保存在一起,以便可以将它们加载到要创建的另一个脚本中。 I have read different tutorials but i dont manage to do it... The variables are like this: 我读过不同的教程,但我没有做到这一点...变量是这样的:

a=['red','yellow',blue']

b=[[A1,F2,G8],[V,N],[I]]

df: containing 40 columns and 32 rows df:包含40列和32行

How can I save them and load in again? 如何保存并重新加载?

Thanks!! 谢谢!!

You just need to put them together. 您只需要将它们放在一起。

Either a tuple, or a dictionary would do. 元组或字典都可以。

You can also write a small class to store everything and write that in the file. 您还可以编写一个小类来存储所有内容并将其写入文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM