如何使用 VAEX 处理日期时间格式?
我是 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.
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]')
I dont know how to handle this issue, so I need your help. What am I doing wrong here?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
vaex.from_csv
基本上是pandas.read_csv
的别名。在 pandas.read_csv 中,有一个参数可以用来指定哪些列应该被解析为日期时间。只需将相同的参数传递给vaex.from_csv
就可以了!The
vaex.from_csv
is basically an alias topandas.read_csv
. Inpandas.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 tovaex.from_csv
and you should be good to go!