0

I'm working with a dataframe structured like this one below:

        A      B         C                 D
group_997    NaN    Purple    JMHKJALJ_06538
group_998    NaN    Pink      JMHKJALJ_04556
group_999    NaN    Red       JMHKJALJ_09211
group_995    NaN    Green     JMHKJALJ_16378
group_996    NaN    Yellow    JMHKJALJ_81324

Now I'd like to find the corresponding value of JMHKJALJ_16378 (column D) on column A (that is group_995). I tried to use:

df[df['A'].str.contains('JMHKJALJ_16378')]

But the output is not correct. How can I do that?

  • 1
    `df[df['D'].str.contains('JMHKJALJ_16378')]` Typeo - should be column `D` not `A` – It_is_Chris Sep 21 '21 at 19:43
  • Ok, and what if I would not know the column of `JMHKJALJ_16378`? Knowing only the value name `JMHKJALJ_16378` how could I obtain his corresponding value on column A? – Iacopo Passeri Sep 21 '21 at 19:47
  • Actually it works but I got this warning: `FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison`, how can I obtain only the output ? – Iacopo Passeri Sep 21 '21 at 20:07
  • [It's considered a bug](https://stackoverflow.com/a/46721064/14277722) I thought this was resolved in newer releases of `pandas`. – Michael Szczesny Sep 21 '21 at 20:12
  • I upgraded pandas but apparently I still got this issue. What a mess However, thank you! – Iacopo Passeri Sep 21 '21 at 20:16
  • You can asked in another question if there is any development on this issue. I can't help with that, because I don't get the warning on google colab. – Michael Szczesny Sep 21 '21 at 20:23

0 Answers0