You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
``
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
The text was updated successfully, but these errors were encountered: