HEX
Server: Apache
System: Linux srv4.garantili.com.tr 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: ekspardev (1006)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/lib64/python3.6/site-packages/pandas/tests/series/methods/test_droplevel.py
import pytest

from pandas import MultiIndex, Series
import pandas._testing as tm


class TestDropLevel:
    def test_droplevel(self):
        # GH#20342
        ser = Series([1, 2, 3, 4])
        ser.index = MultiIndex.from_arrays(
            [(1, 2, 3, 4), (5, 6, 7, 8)], names=["a", "b"]
        )
        expected = ser.reset_index("b", drop=True)
        result = ser.droplevel("b", axis="index")
        tm.assert_series_equal(result, expected)
        # test that droplevel raises ValueError on axis != 0
        with pytest.raises(ValueError, match="No axis named columns"):
            ser.droplevel(1, axis="columns")