A PyQT GUI application for converting InfoLease report outputs into Excel files. Handles parsing and summarizing. Learns where files are meant to be store and compiles monthly and yearly summaries.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
InfoLeaseExtract/venv/Lib/site-packages/pandas/tests/frame/methods/test_swaplevel.py

36 lines
1.2 KiB

import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
swapped = frame["A"].swaplevel()
swapped2 = frame["A"].swaplevel(0)
swapped3 = frame["A"].swaplevel(0, 1)
swapped4 = frame["A"].swaplevel("first", "second")
assert not swapped.index.equals(frame.index)
tm.assert_series_equal(swapped, swapped2)
tm.assert_series_equal(swapped, swapped3)
tm.assert_series_equal(swapped, swapped4)
back = swapped.swaplevel()
back2 = swapped.swaplevel(0)
back3 = swapped.swaplevel(0, 1)
back4 = swapped.swaplevel("second", "first")
assert back.index.equals(frame.index)
tm.assert_series_equal(back, back2)
tm.assert_series_equal(back, back3)
tm.assert_series_equal(back, back4)
ft = frame.T
swapped = ft.swaplevel("first", "second", axis=1)
exp = frame.swaplevel("first", "second").T
tm.assert_frame_equal(swapped, exp)
msg = "Can only swap levels on a hierarchical axis."
with pytest.raises(TypeError, match=msg):
DataFrame(range(3)).swaplevel()