We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
AttributeError
from scipy.signal import convolve2d mine_grid = df.pivot_table(columns='x', index='y', values='mine') counts = convolve2d(mine_grid.astype(complex), np.ones((3, 3)), mode='same').real.astype(int) df['adjacent'] = (counts - mine_grid).ravel('F') df
AttributeError: 'DataFrame' object has no attribute 'ravel'
df['adjacent'] = (counts - mine_grid).to_numpy().ravel('F')
Alternative solution
from numpy.lib.stride_tricks import sliding_window_view arr = df['mine'].values.reshape(5, 4) df['adjacent'] = (sliding_window_view(np.pad(arr, 1), window_shape=(3, 3)).sum(axis=(-2, -1))-arr).ravel() print(df)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
AttributeError
Alternative solution
The text was updated successfully, but these errors were encountered: