Use
is
when comparing type
of two objects17year_set = [
18 year
19 for year in list(OrderedDict.fromkeys(years.values[0]).keys())
20 if type(year) == str21]
22
23process = data[6:]
Use
is
when comparing type
of two objects 22year_set = [
23 year
24 for year in list(OrderedDict.fromkeys(years.values[0]).keys())
25 if type(year) == str 26]
27process = data[5:]
28headers = data.iloc[4][2:-2]
Description
It is recommended to use identity test
( is
) instead of equality test ( ==
) when you need to compare types of two objects.
Bad practice
if type(x) == str:
print(x)
Recommended
if type(x) is str:
print(x)
# Alternatively,
if isinstance(x, str):
print(x)