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

Fix deprecated assignment method in 'ball_hit' column to resolve SettingWithCopyWarning #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Akb-25
Copy link

@Akb-25 Akb-25 commented Aug 3, 2024

Summary

This commit updates the assignment method for the 'ball_hit' column in the DataFrame to use .loc instead of .iloc.

Details

The previous implementation used .iloc for direct assignment, which triggered a SettingWithCopyWarning. This warning occurred due to potential issues with chained indexing and DataFrame views, which can lead to unintended behavior.

Changes Made

  • Replaced direct assignment with .iloc from df_ball_positions['ball_hit'].iloc[i] = 1 to .loc as df_ball_positions.loc[i, 'ball_hit'] = 1.
  • This update ensures that the assignment is applied directly to the DataFrame, avoiding the warning and following best practices for DataFrame modifications.

Testing

  • Verified that the new method prevents SettingWithCopyWarning and correctly updates the DataFrame.
  • Ran existing tests to ensure that no new issues were introduced.

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

Successfully merging this pull request may close these issues.

1 participant