0

I have a dataframe (df_test).

df_test = pd.DataFrame({'col1': ["A", "D", "F", "G","W", "S"], 'col2': [4, 0, 2, 1,3,4]},index=['a', 'b', 'c', 'd', 'e', 'f'])

I want to select rows whose values of col1 are included in List_test.

List_test =["A", "B", "C"]

I wrote

df_test[df_test["col1"] in List_test]

but the following error took place.

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

How can I fix this?

Apppii092
  • 1
  • 1
  • [Series.isin](https://pandas.pydata.org/docs/reference/api/pandas.Series.isin.html) -> `df_test[df_test["col1"].isin(List_test)]` – Henry Ecker Oct 18 '21 at 02:34

0 Answers0