title: Filtering DataFrame Columns by Specific Value in Row
body: <p>I had a small question regarding the possibility to filter a Dataframe in Python.
  The Dataframe has various rows containing strings and integers. The row of interest is called “numbervalues” which contains numbers from 1 until 30, sometimes containing multiple entries (i.e. not only “1” but also “1+2” or &quot;1;2&quot;). I want to filter for the columns containing the number “5” in the row. I tried various lines of code such as</p>
  <p>df[df[“numbervalues”].astype(str).str.contains(“5”)]</p>
  <p>or</p>
  <p>df[df[“numbervalues”] == “5”]</p>
  <p>The problem is that the first option is too inclusive / broad as it also includes numbers such as “15” which I don’t want to select. The second option however is too selective, as it does not catch the rows that have multiple values such as “5+3” or &quot;5;9&quot;
  I also thought about dropping values such as “15” and “25” to exclude these sets, but some rows contain “5+15” thus I would also be dropping relevant values from my dataset.
  Any help is greatly appreciated.</p>