0
df['sign'] = np.where(dA['purple'] >=dd['ve'], 'positive', 'negative')

I got this error: ValueError: Can only compare identically-labeled Series objects

hpaulj
  • 221,503
  • 14
  • 230
  • 353
  • Is your question what "identically-labeled" means? – mkrieger1 Aug 13 '22 at 21:10
  • Do `all(df.index == dd.index)`. If the answer is `False`, [that's the problem](https://stackoverflow.com/questions/51067449/valueerror-can-only-compare-identically-labeled-series-objects-python). – Ignatius Reilly Aug 13 '22 at 21:12
  • df and dd is a data frame contains other columnes – suuuuuuuuuu Aug 13 '22 at 21:15
  • my question is how to colomnes with diferent labeld – suuuuuuuuuu Aug 13 '22 at 21:17
  • Please consider adding a [MRE](https://stackoverflow.com/help/minimal-reproducible-example) to your question. This is the most sure-fire way to get an useful answer. – CryptoFool Aug 13 '22 at 21:28
  • "identically-labeled" means that the two dataframes should have the same index. Otherwise, pandas wouldn't know how to compare them (which row of `df` corresponds to which row of `dd`). The columns don't need to be the same. See the answer in the link from my previous comment. – Ignatius Reilly Aug 13 '22 at 21:29
  • The error is probably caused by: `dA['purple'] >=dd['ve']`. `dA` and `dd` must be dataframes with different row indices. This comparison is not allowed (by `pandas`) – hpaulj Aug 14 '22 at 00:47

0 Answers0