如何在加载镶木quet文件时单独添加标头行?

发布于 2025-01-25 03:24:59 字数 387 浏览 3 评论 0原文

在处理CSV文件时,我们可以说:

df = pd.read_csv("test.csv", names=header_list, dtype=dtype_dict)

以上将在dtype_dict中以header_list和dtypes创建一个数据框,

我们可以使用pd._read_parquet()做类似的事情吗?

我的问题涉及单独传递标题,因此在“ test.csv”中不可用
绕过的另一种方法可能是将DF中的整个数据向下移动1(包括将标题转换为行),然后用header_list替换标题(甚至可能吗?)

是否有最佳解决方案? 我对镶木木不太熟悉,因此任何指导都将不胜感激,谢谢。

While handling csv files we can say:

df = pd.read_csv("test.csv", names=header_list, dtype=dtype_dict)

Above would create a dataframe with headers as header_list and dtypes as of the dtype_dict

Can we do something similar with pd.read_parquet() ?

My issue involves passing in headers separately and would thus not be available in the "test.csv"
Another way to bypass it could be to move the entire data in df downwards by 1 (including shifting headers into rows) and then replacing the header with header_list (if it's even possible?)

Is there an optimal solution to my issue?
I'm not too familiar with parquet so any guidance would be appreciated, thanks.

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

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

发布评论

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

评论(1

静赏你的温柔 2025-02-01 03:24:59

我们可以做类似的pd._read_parquet()?

镶木文件包含一些元数据,包括列的名称及其类型。因此,加载数据时无需传递此信息。

Can we do something similar with pd.read_parquet() ?

parquet files contain some metadata, including the name of the columns and their types. So there is no need to pass this information when loading the data.

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