pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.1k stars 1.94k forks source link

Support integer period on a temporal column #18395

Open eromoe opened 2 months ago

eromoe commented 2 months ago

Description

I want to groupby rolling apply a column, and join the result back to main df as a new feature:

df = df.with_columns(
    pl.col('close').sort_by('date').log().diff().over("code").alias("log_return"),
)

df_vola_28 = df.group_by_dynamic(
    'date',
    every='1i',
    period='28i',
    group_by='code',
).agg(
    pl.col('log_return').pow(2).sum().sqrt().alias('vola_28')
)

df = df.join(df_vola_28, on=['code','date'])

Here, date colume is not continuous, so I have to use integer period , but get error when df_vola_28.head(10).collect()

InvalidOperationError: `every` duration may not be a parsed integer (i.e. use '2d', not '2i') when working with a temporal column

change every='1d' and keep period='28i get

InvalidOperationError: `period` duration may not be a parsed integer (i.e. use '2d', not '2i') when working with a temporal column
eromoe commented 2 months ago

@jia6214876 Unfortunately, I think there is no gcc on Windows .

orlp commented 2 months ago

@eromoe I'm afraid the account you responded to was a malicious actor trying to get you to download and execute malware. Our repository is being targeted by bots doing this =/ It seems Github deleted the account.