如何使用 VAEX 处理日期时间格式?

发布于 2025-01-15 02:16:37 字数 751 浏览 2 评论 0原文

我是 VAEX 新手。另外,我在谷歌中找不到我的具体问题的任何解决方案。所以我在这里问希望有人能解决我的问题:)。

我正在使用 VAEX 从 DASH Plotly 应用程序中的 CSV 文件导入数据,然后想要在 VAEX 中将日期列转换为日期时间格式。它成功地从 csv 文件导入数据。以下是我将数据从 csv 导入 VAEX 的方法:

vaex_df=vaex.from_csv(link,convert=True,chunk_size=5_000)

下面显示了导入 VAEX 后日期列的类型。如您所见,它将日期列作为字符串类型。

输入图片此处描述

然后,当我尝试使用以下代码更改日期列的数据类型时,会出现错误:

vaex_df['Date']=vaex_df['Date'].astype('datetime64[ns]')

在此处输入图像描述

我不知道如何处理这个问题,所以我需要你的帮助。我在这里做错了什么? 提前致谢

I am new to VAEX. Also I couldn't find any solution for my specific question in google. So I am asking here hoping someone can solve my issue :).

I am using VAEX to import data from CSV file in my DASH Plotly app and then want to convert Date column to datetime format within VAEX. It successfully imports the data from csv file. Here is how I imported data from csv into VAEX:

vaex_df=vaex.from_csv(link,convert=True,chunk_size=5_000)

Below it shows the type of the Date column after importing into VAEX. As you can see, it takes the Date column as string type.

enter image description here

Then when I try to change data type of Date columns with below code, it gives error:

vaex_df['Date']=vaex_df['Date'].astype('datetime64[ns]')

enter image description here

I dont know how to handle this issue, so I need your help. What am I doing wrong here?
Thanks in advance

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

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

发布评论

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

评论(1

夏见 2025-01-22 02:16:37

vaex.from_csv 基本上是 pandas.read_csv 的别名。在 pandas.read_csv 中,有一个参数可以用来指定哪些列应该被解析为日期时间。只需将相同的参数传递给 vaex.from_csv 就可以了!

The vaex.from_csv is basically an alias to pandas.read_csv. In pandas.read_csv there is an argument that use can use to specify which columns should be parsed as datetime. Just pass that very same argument to vaex.from_csv and you should be good to go!

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