I have been trying to get the rows of a Dataframe that fullfill certain condition but it takes a really long time to complete. What I have is
latitud codigoSerial nombre longitud variableConsulta fecha
6.379038 3 Girardota - S.O.S Aburrá Norte -75.450913 pm25 2018-08-28
And it goes like that but with 183981 rows and I have to get all the ones that have the word "Medellin" in nombre
What I did was to use to check which codigoSerial were used by Medellin and put all of them on a list, then I started to iterate over the dataframe checking if its codigoSerial were on the list and if it were the row was append on a different dataframe, is there any other more efficient option?
cod = [25,44,79,80,83,84,85,86]
final2 = pd.DataFrame(columns = ["latitud", "codigoSerial", "nombre", "nombreCorto", "longitud", "variableConsulta", "fecha", "calidad", "valor"])
indices = []
for i in range(len(antioquia["codigoSerial"])):
if antioquia["codigoSerial"].iloc[i] in cod:
indices.append(i)
for i in indices:
final2 = final2.append(antioquia.iloc[i])