在Google-Colab pandas.read_pickle()

发布于 2025-01-17 14:03:45 字数 123 浏览 3 评论 0原文

我使用 pd.to_pickle() 从我的计算机制作了一个数据帧的 pickle 文件,但我无法在 colab 中读取该文件。它给出错误ValueError:不支持的pickle协议:5。请给出解决方案。

I made a pickle file of a dataframe from my computer using pd.to_pickle() which I could not read in colab. It gives error ValueError: unsupported pickle protocol: 5. Please give a solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随遇而安 2025-01-24 14:03:45

您需要首先安装 pickle5,使用:

!pip install pickle5

然后,

#Import the library
import pickle5 as pickle

path = 'path_to_pickle5'

with open(path, "rb") as dt:
  df = pickle.load(dt)

You need to install pickle5 first, using:

!pip install pickle5

Then,

#Import the library
import pickle5 as pickle

path = 'path_to_pickle5'

with open(path, "rb") as dt:
  df = pickle.load(dt)
记忆之渊 2025-01-24 14:03:45

我在尝试打开“pickled”pd.dataframe 时遇到了类似的问题。对我来说,解决方案是升级 google colab 笔记本的默认 pandas 版本。从 1.3.5 到 1.5.2

点!安装pandas==1.5.2

重启内核

I was in a similar problem trying to open a "pickled" pd.dataframe. The solution for me was upgrade the default pandas version of google colab notebook. From 1.3.5 to 1.5.2

pip! install pandas==1.5.2

restart kernel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文