-1
Hello, I have the following question: I have two dataframes and I want to check if the values of one column contain in another column of another dataframe that does not have the same name nor the same order One column has 22,000 lines and the other has 48,000 lines. In case I want to check if the id of one column has in another and if yes return only the lines that match. For example df1 has a column with the following values,
column = [ '1', '2', '3', '4', '5']
in df2
column2 = ['1', '3']
I want to return the lines of df1 that contains the values of the df2 column
curso = cursos.where(cursos['CÓDIGO UNIDADE DE ENSINO'] == cursoAtivo['CO_UNIDADE_ENSINO']).notna()
I received the following error for the above code Can only compare identically-labeled Series Objects
can make a minimal replicable example?
– Lucas
Hi Lucas, I tried to explain more clearly. The name of the columns are not identical
– Laís
You want to know
coluna2
all or part of it?– Paulo Marques
I want to know the whole column
– Laís
For a hunch, it would be something like this
>>>df = curso.where(cursos['CÓDIGO UNIDADE DE ENSINO'].isin(cursoAtivo['CO_UNIDADE_ENSINO']))
,>>>curso = df.dropna(0, subset=["coluna"], inplace=True)
.I ask you to edit the question and put a sample of the two Dataframes involved so you can provide an accurate and documented answer.– Augusto Vasques