The following code throws ValueError: unknown type str32 for string comparison
:
import pandas as pd
# Loading in some bigger data from Kaggle https://www.kaggle.com/dgomonov/new-york-city-airbnb-open-data
# data and code file included in zip to make it easy
df = pd.read_csv("AB_NYC_2019.csv")
print(df == "x") # throws ValueError
It seems that the last line of code is legitimate. What is done wrong?
This error is related with the bug that affected pandas
version 1.1.0 and some versions prior to 1.0.5. It has been fixed in version 1.1.3.
Therefore, to make it go away it is recommended to upgrade pandas
to version 1.1.3.
The bug does not manifest in smaller datasets (or the ones not loaded from CSV).