简体   繁体   English

Python性能问题 - 从特定的Pickle文件中读取相同Pandas数据帧的多个方法

[英]Python Performance concern - Multiple methods reading same Pandas Data Frame from a particular Pickle file

We have multiple (4) methods reading the same Pandas Data Frame from a particular / the same - Pickle file stored on the local directory. 我们有多个(4)方法从特定/相同的文件中读取相同的Pandas数据框 - 存储在本地目录中的Pickle文件。 Code creating the only pickle file as below :- 代码创建唯一的pickle文件如下: -

df_for_bokeh = pd.read_sql(sql_command,engine)
df_for_bokeh.to_pickle("./df_holoviewPlots.pkl")

Code snippets from the methods reading the pickle file as below :- 读取pickle文件的方法的代码片段如下: -

df_for_bokeh = pd.read_pickle("./df_holoviewPlots.pkl")
df_for_bokeh1 = pd.read_pickle("./df_holoviewPlots.pkl")
df_for_bokeh2 = pd.read_pickle("./df_holoviewPlots.pkl")
df_for_bokeh3 = pd.read_pickle("./df_holoviewPlots.pkl")

As seen above My concern with performance is - would this be better or should we pickle the DF into 4 separate in place of the same Pickle file. 如上所述,我对性能的关注是 - 这会更好还是应该将DF腌制成4个单独的Pickle文件。

We can not have the pickle file - unpickled to give only 1 DataFrame . 我们不能有pickle文件 - unpickled只提供1个DataFrame。 We shall need atleast - 4 different data frames to be read from the one Pickle file , and that too almost at the same time. 我们需要至少 - 从一个Pickle文件中读取4个不同的数据帧,而且几乎同时也是如此。

Is there a reason you can't do the following: 有没有理由你不能做到以下几点:

  1. Set a loading lock state 设置加载锁定状态
  2. Load the date once 加载日期一次
  3. Deep copy to as many objects as you need https://docs.python.org/3.7/library/copy.html 深度复制到您需要的任意数量的对象https://docs.python.org/3.7/library/copy.html
  4. Release the loading lock state 释放加载锁定状态

This would give you the same data in 4 different independent data frames. 这将在4个不同的独立数据帧中提供相同的数据。

暂无
暂无

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

相关问题 在 R 中读取泡菜文件(PANDAS Python 数据帧) - Reading a pickle file (PANDAS Python Data Frame) in R 在 python 中读取 RDa 文件作为 Pandas 数据框 - reading RDa file in python as a pandas data frame 如何使用pandas read_pickle从qrc资源文件中读取包含pandas数据框的pickle文件? - How can I read pickle file containing pandas data frame from qrc resource file with pandas read_pickle? 在将 python pickle 数据写入文件之前读取它 - Reading python pickle data before writing it to a file 在python中使用pickle和for循环从文件中读取 - Reading from a file using pickle and for loop in python 在 tar.z 文件中读取为 python 3.7.4 中的 pandas 数据帧? - reading in tar.z file as pandas data frame in python 3.7.4? 将多个csv文件读入Pandas数据框 - Reading multiple csv files into a Pandas Data Frame 如何从包含特定列中的特定字符串(多个)的 Pandas 数据框中删除行? - How to drop rows from pandas data frame that contains a particular string(multiple) in a particular column? Python Pandas - 通过匹配主标识符将多个数据帧中的数据附加到同一行,如果没有来自该数据帧的结果则留空 - Python Pandas - Appending data from multiple data frames onto same row by matching primary identifier, leave blank if no results from that data frame Python pandas:根据条件从多个数据框中访问数据 - Python pandas: Accessing data from multiple data frame based on condition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM