解决 ValueError: Can only compare identically-labeled Series object

报错如下:

File “/root/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py”, line 1676, in wrapper
raise ValueError("Can only compare identically-labeled "
ValueError: Can only compare identically-labeled Series objects

代码:

a = c[c["m"]==sample["d"]]

原因:
sample[“d”]得到的是一个series object

解决:

a = c[c["m"]==sample["d"].squeeze()]

Reference:
https://stackoverflow.com/questions/45724817/valueerror-can-only-compare-identically-labeled-series-objects

你可能感兴趣的:(python3,pandas,问题解决)