code: def test_xs(self):
      d = {
          "num_legs": [4, 4, 2, 2],
          "num_wings": [0, 0, 2, 2],
          "class": ["mammal", "mammal", "mammal", "bird"],
          "animal": ["cat", "dog", "bat", "penguin"],
          "locomotion": ["walks", "walks", "flies", "walks"],
      }
      pdf = pd.DataFrame(data=d)
      pdf = pdf.set_index(["class", "animal", "locomotion"])
      psdf = ps.from_pandas(pdf)
  
      self.assert_eq(psdf.xs("mammal"), pdf.xs("mammal"))
      self.assert_eq(psdf.xs(("mammal",)), pdf.xs(("mammal",)))
      self.assert_eq(
          psdf.xs(("mammal", "dog", "walks")),
          pdf.xs(("mammal", "dog", "walks")),
      )
      self.assert_eq(
          ps.concat([psdf, psdf]).xs(("mammal", "dog", "walks")),
          pd.concat([pdf, pdf]).xs(("mammal", "dog", "walks")),
      )
      self.assert_eq(psdf.xs("cat", level=1), pdf.xs("cat", level=1))
      self.assert_eq(
          psdf.xs("flies", level=2), pdf.xs("flies", level=2)
      )
      self.assert_eq(
          psdf.xs("mammal", level=-3), pdf.xs("mammal", level=-3)
      )
  
      msg = 'axis should be either 0 or "index" currently.'
      with self.assertRaisesRegex(NotImplementedError, msg):
          psdf.xs("num_wings", axis=1)
      with self.assertRaises(KeyError):
          psdf.xs(("mammal", "dog", "walk"))
      msg = r"'Key length \(4\) exceeds index depth \(3\)'"
      with self.assertRaisesRegex(KeyError, msg):
          psdf.xs(("mammal", "dog", "walks", "foo"))
      msg = "'key' should be a scalar value or tuple that contains scalar values"
      with self.assertRaisesRegex(TypeError, msg):
          psdf.xs(["mammal", "dog", "walks", "foo"])
  
      self.assertRaises(IndexError, lambda: psdf.xs("foo", level=-4))
      self.assertRaises(IndexError, lambda: psdf.xs("foo", level=3))
  
      self.assertRaises(
          KeyError, lambda: psdf.xs(("dog", "walks"), level=1)
      )
  
      # non-string names
      pdf = pd.DataFrame(data=d)
      pdf = pdf.set_index(["class", "animal", "num_legs", "num_wings"])
      psdf = ps.from_pandas(pdf)
  
      self.assert_eq(
          psdf.xs(("mammal", "dog", 4)), pdf.xs(("mammal", "dog", 4))
      )
      self.assert_eq(psdf.xs(2, level=2), pdf.xs(2, level=2))
  
      self.assert_eq(
          (psdf + "a").xs(("mammal", "dog", 4)),
          (pdf + "a").xs(("mammal", "dog", 4)),
      )
      self.assert_eq(
          (psdf + "a").xs(2, level=2), (pdf + "a").xs(2, level=2)
      )
  
imports: import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.pandas.config import option_context
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 7 for calling the FrameIndexingMixin obj's underlying member method code with example usage: obj.test_xs() without return types