# drop nan value for event_type2 and player2
nan_value = df[df["event_type2"].notnull() & df["player2"].isnull()].index.tolist()
print("\nThe value of event_type2 and player2 nan value is: ", len(nan_value))
df = df.drop(nan_value)
print("\nThe new dimension od dataset without nan value of event_type2 and player2 is: ", df.shape)
My dataframe before this code had a size of 941009 samples, after dropping these rows the new size is 936353, and so far everything is fine.
# fill remained nan value for event_type2 and player2
df['player2'].fillna(value="Nobody", inplace=True)
df['event_type2'].fillna(value=16, inplace=True)
print(df.info())
# manage player nan value
nan_player = df[df["player"].isnull()].index.tolist()
print(nan_player)
text_nan_player = df.index[nan_player]
The problem arises when I access the indices of these samples, because it tells me that the indices go beyond 936353, but my question is: how is it possible since the size of my dataset is just 936353?
this is the error it gives me: IndexError: index 936358 is out of bounds for axis 0 with size 936353.
I'm going crazy with this, thanks anyway.