Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vaex dataframe.rolling #2423

Open
KKalleKK opened this issue May 6, 2024 · 0 comments
Open

vaex dataframe.rolling #2423

KKalleKK opened this issue May 6, 2024 · 0 comments

Comments

@KKalleKK
Copy link

KKalleKK commented May 6, 2024

Hello, author. Recently, I encountered an issue with vaex when using vaex dataframe.rolling. When I attempt try_rolling_obj = try_group_df.rolling(window=window, trim=False, edge='right', column=['c']), even though my data is complete without any missing values, it still leads to a ValueError: could not broadcast input array from shape (199,) into shape (0,) problem. I'd like to understand which part needs adjustment and what your suggestions are for resolving this. Thank you for your help.
The following is the code and files I am attaching.
``
#%% ValueError: could not broadcast input array from shape (199,) into shape (0,)
import vaex
try = vaex.from_csv(r'your_path', sep='\t')

window=252
try_groups = try.groupby(['m'], sort=True)
for try_secid, try_group_df in try_groups :
if len(try_group_df) >= window:
try_group_df_value=try_group_df.to_pandas_df()
# This method is used to create a new DataFrame containing the same data and structure.
try_group_copy=try_group_df.extract()
# Create rolling objects for each group and calculate the required rolling statistics.
try_rolling_obj =try_group_df.rolling(window=window, trim=False, edge='right', column=['c'])
# Rolling mean for each group of 'window' elements.
try_group_copy['rolling_mean']= (try_rolling_obj.sum()['c']/window).values
``

input.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant