Oct-07-2019, 01:40 PM
hi, i have data i downloaded from the internet so it is not in a structured table, there are rows i want to delete. using a regex, i am able to identify the rows but dropping them from the dataframe and displaying a new dataframe based on dropped rows is my challenge. the new df should display the data without these rows..
here is the code and a pic of data
![[Image: uc?id=1uLeosDrR7v2W1Z2Jw73FBu__6sy063X_]](https://drive.google.com/uc?id=1uLeosDrR7v2W1Z2Jw73FBu__6sy063X_)
i ended up placing the index row in a list and dropping the list. this worked. is there a better way?
here is the code and a pic of data
for i in df.index: if any(re.findall(r'HOME ADVANTAGE|RATING|through games of', df.iloc[i,0] ) ): df.drop(df.iloc[i,0], inplace=False) print(df)
i ended up placing the index row in a list and dropping the list. this worked. is there a better way?
rows=[] for i in df.index: if any(re.findall(r'HOME ADVANTAGE|RATING|through games of', df.iloc[i,0] ) ): rows.append(i) df = df.drop(rows) print(df)