jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def test_rowspan_w3():
    # GH 38533
    df = DataFrame(data=[[1, 2]], index=[["l0", "l0"], ["l1a", "l1b"]])
    styler = Styler(df, uuid="_", cell_ids=False)
    assert '<th class="row_heading level0 row0" rowspan="2">l0</th>' in styler.to_html()
//  [python]
def test_rowspan_w3():
    # GH 38533
    df = DataFrame(data=[[1, 2]], index=[["l0", "l0"], ["l1a", "l1b"]])
    styler = Styler(df, uuid="_", cell_ids=False)
    assert (
        '<th id="T___level0_row0" class="row_heading '
        'level0 row0" rowspan="2">l0</th>' in styler.render()
    )
//  [python]
def test_rowspan_w3():
    # GH 38533
    df = DataFrame(data=[[1, 2]], index=[["l0", "l0"], ["l1a", "l1b"]])
    styler = Styler(df, uuid="_", cell_ids=False)
    assert (
        '<th id="T___level0_row0" class="row_heading '
        'level0 row0" rowspan="2">l0</th>' in styler.to_html()
    )
//  [python]
def test_caption(self, df):
        styler = Styler(df, caption="foo")
        result = styler.to_html()
        assert all(["caption" in result, "foo" in result])

        styler = df.style
        result = styler.set_caption("baz")
        assert styler is result
        assert styler.caption == "baz"
//  [python]
def test_uuid(self, df):
        styler = Styler(df, uuid="abc123")
        result = styler.to_html()
        assert "abc123" in result

        styler = df.style
        result = styler.set_uuid("aaa")
        assert result is styler
        assert result.uuid == "aaa"
//  [python]
def test_table_attributes(self, df):
        attributes = 'class="foo" data-bar'
        styler = Styler(df, table_attributes=attributes)
        result = styler.render()
        assert 'class="foo" data-bar' in result

        result = df.style.set_table_attributes(attributes).render()
        assert 'class="foo" data-bar' in result
//  [python]
def test_table_attributes(self, df):
        attributes = 'class="foo" data-bar'
        styler = Styler(df, table_attributes=attributes)
        result = styler.to_html()
        assert 'class="foo" data-bar' in result

        result = df.style.set_table_attributes(attributes).to_html()
        assert 'class="foo" data-bar' in result
//  [python]
def test_no_cell_ids(self):
        # GH 35588
        # GH 35663
        df = DataFrame(data=[[0]])
        styler = Styler(df, uuid="_", cell_ids=False)
        styler.to_html()
        s = styler.to_html()  # render twice to ensure ctx is not updated
        assert s.find('<td class="data row0 col0" >') != -1
//  [python]
def test_table_styles(self, df):
        style = [{"selector": "th", "props": [("foo", "bar")]}]  # default format
        styler = Styler(df, table_styles=style)
        result = " ".join(styler._repr_html_().split())
        assert "th { foo: bar; }" in result

        styler = df.style
        result = styler.set_table_styles(style)
        assert styler is result
        assert styler.table_styles == style

        # GH 39563
        style = [{"selector": "th", "props": "foo:bar;"}]  # css string format
        styler = df.style.set_table_styles(style)
        result = " ".join(styler._repr_html_().split())
        assert "th { foo: bar; }" in result
//  [python]
def test_table_styles(self, df):
        style = [{"selector": "th", "props": [("foo", "bar")]}]  # default format
        styler = Styler(df, table_styles=style)
        result = " ".join(styler.to_html().split())
        assert "th { foo: bar; }" in result

        styler = df.style
        result = styler.set_table_styles(style)
        assert styler is result
        assert styler.table_styles == style

        # GH 39563
        style = [{"selector": "th", "props": "foo:bar;"}]  # css string format
        styler = df.style.set_table_styles(style)
        result = " ".join(styler.to_html().split())
        assert "th { foo: bar; }" in result
//  [python]
def test_column_and_row_styling(self):
        # GH 35607
        df = DataFrame(data=[[0, 1], [1, 2]], columns=["A", "B"])
        s = Styler(df, uuid_len=0)
        s = s.set_table_styles({"A": [{"selector": "", "props": [("color", "blue")]}]})
        assert "#T_ .col0 {\n  color: blue;\n}" in s.to_html()
        s = s.set_table_styles(
            {0: [{"selector": "", "props": [("color", "blue")]}]}, axis=1
        )
        assert "#T_ .row0 {\n  color: blue;\n}" in s.to_html()
//  [python]
def test_swapaxes_read_only_array():
    df = DataFrame({"a": [1, 2], "b": 3})
    df = df.swapaxes(axis1="index", axis2="columns")
    df.iloc[0, 0] = 100
    expected = DataFrame({0: [100, 3], 1: [2, 3]}, index=["a", "b"])
    tm.assert_frame_equal(df, expected)
//  [python]
def test_swapaxes_read_only_array():
    df = DataFrame({"a": [1, 2], "b": 3})
    df = df.transpose()
    df.iloc[0, 0] = 100
    expected = DataFrame({0: [100, 3], 1: [2, 3]}, index=["a", "b"])
    tm.assert_frame_equal(df, expected)
//  [python]
def test_swapaxes(self):
        df = DataFrame(np.random.randn(10, 5))
        assert_frame_equal(df.T, df.swapaxes(0, 1))
        assert_frame_equal(df.T, df.swapaxes(1, 0))
        assert_frame_equal(df, df.swapaxes(0, 0))
        self.assertRaises(ValueError, df.swapaxes, 2, 5)
//  [python]
def test_swapaxes(self):
        df = DataFrame(np.random.randn(10, 5))
        assert_frame_equal(df.transpose(), df.transpose())
        assert_frame_equal(df.transpose(), df.transpose())
        assert_frame_equal(df, df.transpose().transpose())
        self.assertRaises(ValueError, df.transpose, 2, 5)
//  [python]
def test_swapaxes_noop(using_copy_on_write, ax):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    df_orig = df.copy()
    df2 = df.swapaxes(ax, ax)

    if using_copy_on_write:
        assert np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
    else:
        assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))

    # mutating df2 triggers a copy-on-write for that column/block
    df2.iloc[0, 0] = 0
    if using_copy_on_write:
        assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_swapaxes_noop(using_copy_on_write, ax):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    df_orig = df.copy()
    df2 = df.transpose()

    if using_copy_on_write:
        assert np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
    else:
        assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))

    # mutating df2 triggers a copy-on-write for that column/block
    df2.iloc[0, 0] = 0
    if using_copy_on_write:
        assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_swapaxes(data, axis1, axis2):
    modin_df = pd.DataFrame(data)
    pandas_df = pandas.DataFrame(data)

    pandas_result = pandas_df.swapaxes(axis1, axis2)
    modin_result = modin_df.swapaxes(axis1, axis2)
    df_equals(modin_result, pandas_result)
//  [python]
def test_swapaxes(data, axis1, axis2):
    modin_df = pd.DataFrame(data)
    pandas_df = pandas.DataFrame(data)

    pandas_result = pandas_df.transpose(*[axis1, axis2])
    modin_result = modin_df.transpose(*[axis1, axis2])
    df_equals(modin_result, pandas_result)
//  [python]
def test_swapaxes_single_block(using_copy_on_write):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=["x", "y", "z"])
    df_orig = df.copy()
    df2 = df.swapaxes("index", "columns")

    if using_copy_on_write:
        assert np.shares_memory(get_array(df2, "x"), get_array(df, "a"))
    else:
        assert not np.shares_memory(get_array(df2, "x"), get_array(df, "a"))

    # mutating df2 triggers a copy-on-write for that column/block
    df2.iloc[0, 0] = 0
    if using_copy_on_write:
        assert not np.shares_memory(get_array(df2, "x"), get_array(df, "a"))
    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_swapaxes_single_block(using_copy_on_write):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}, index=["x", "y", "z"])
    df_orig = df.copy()
    df2 = df.transpose()

    if using_copy_on_write:
        assert np.shares_memory(get_array(df2, "x"), get_array(df, "a"))
    else:
        assert not np.shares_memory(get_array(df2, "x"), get_array(df, "a"))

    # mutating df2 triggers a copy-on-write for that column/block
    df2.iloc[0, 0] = 0
    if using_copy_on_write:
        assert not np.shares_memory(get_array(df2, "x"), get_array(df, "a"))
    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_swapaxes(self):
        pdf = pd.DataFrame(
            [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["x", "y", "z"], columns=["a", "b", "c"]
        )
        psdf = ps.from_pandas(pdf)

        self.assert_eq(psdf.swapaxes(0, 1), pdf.swapaxes(0, 1))
        self.assert_eq(psdf.swapaxes(1, 0), pdf.swapaxes(1, 0))
        self.assert_eq(psdf.swapaxes("index", "columns"), pdf.swapaxes("index", "columns"))
        self.assert_eq(psdf.swapaxes("columns", "index"), pdf.swapaxes("columns", "index"))
        self.assert_eq((psdf + 1).swapaxes(0, 1), (pdf + 1).swapaxes(0, 1))

        self.assertRaises(AssertionError, lambda: psdf.swapaxes(0, 1, copy=False))
        self.assertRaises(ValueError, lambda: psdf.swapaxes(0, -1))
//  [python]
def test_swapaxes(self):
        pdf = pd.DataFrame(
            [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["x", "y", "z"], columns=["a", "b", "c"]
        )
        psdf = ps.from_pandas(pdf)

        self.assert_eq(psdf.transpose(), pdf.transpose())
        self.assert_eq(psdf.transpose(), pdf.transpose())
        self.assert_eq(psdf.transpose(), pdf.transpose())
        self.assert_eq(psdf.transpose(), pdf.transpose())
        self.assert_eq((psdf + 1).transpose(), (pdf + 1).transpose())

        self.assertRaises(AssertionError, lambda: psdf.transpose(copy=False))
        self.assertRaises(ValueError, lambda: psdf.transpose(0, -1))
//  [python]
def test_swapaxes(self):
        pdf = pd.DataFrame(
            [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["x", "y", "z"], columns=["a", "b", "c"]
        )
        kdf = ks.from_pandas(pdf)

        self.assert_eq(kdf.swapaxes(0, 1), pdf.swapaxes(0, 1))
        self.assert_eq(kdf.swapaxes(1, 0), pdf.swapaxes(1, 0))
        self.assert_eq(kdf.swapaxes("index", "columns"), pdf.swapaxes("index", "columns"))
        self.assert_eq(kdf.swapaxes("columns", "index"), pdf.swapaxes("columns", "index"))
        self.assert_eq((kdf + 1).swapaxes(0, 1), (pdf + 1).swapaxes(0, 1))

        self.assertRaises(AssertionError, lambda: kdf.swapaxes(0, 1, copy=False))
        self.assertRaises(ValueError, lambda: kdf.swapaxes(0, -1))
//  [python]
def test_swapaxes(self):
        pdf = pd.DataFrame(
            [[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["x", "y", "z"], columns=["a", "b", "c"]
        )
        kdf = ks.from_pandas(pdf)

        self.assert_eq(kdf.transpose(), pdf.transpose())
        self.assert_eq(kdf.transpose(), pdf.transpose())
        self.assert_eq(kdf.transpose(), pdf.transpose())
        self.assert_eq(kdf.transpose(), pdf.transpose())
        self.assert_eq((kdf + 1).transpose(), (pdf + 1).transpose())

        self.assertRaises(AssertionError, lambda: kdf.transpose(copy=False))
        self.assertRaises(ValueError, lambda: kdf.swapaxes(0, -1))
//  [python]
def testDataFrameNumpy(self):
        df = DataFrame([[1,2,3], [4,5,6]], index=['a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df), numpy=True))
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split"),
                          numpy=True))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index"), numpy=True))
        self.assertTrue((df.T == outp).values.all())
        assert_array_equal(df.T.columns, outp.columns)
        assert_array_equal(df.T.index, outp.index)
//  [python]
def testDataFrameNumpy(self):
        df = DataFrame([[1,2,3], [4,5,6]], index=['a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df), numpy=True))
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split"),
                          numpy=True))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index"), numpy=True))
        self.assertTrue((df.transpose() == outp).values.all())
        assert_array_equal(df.transpose().columns, outp.columns)
        assert_array_equal(df.transpose().index, outp.index)
//  [python]
def testDataFrame(self):
        df = DataFrame([[1,2,3], [4,5,6]], index=['a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df)))
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split")))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="records")))
        outp.index = df.index
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="values")))
        outp.index = df.index
        self.assertTrue((df.values == outp.values).all())

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index")))
        self.assertTrue((df.T == outp).values.all())
        assert_array_equal(df.T.columns, outp.columns)
        assert_array_equal(df.T.index, outp.index)
//  [python]
def testDataFrame(self):
        df = DataFrame([[1,2,3], [4,5,6]], index=['a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df)))
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split")))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)
        assert_array_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="records")))
        outp.index = df.index
        self.assertTrue((df == outp).values.all())
        assert_array_equal(df.columns, outp.columns)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="values")))
        outp.index = df.index
        self.assertTrue((df.values == outp.values).all())

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index")))
        self.assertTrue((df.transpose() == outp).values.all())
        assert_array_equal(df.transpose().columns, outp.columns)
        assert_array_equal(df.transpose().index, outp.index)
//  [python]
def test_dataframe(self, orient):
        dtype = np.int64

        df = DataFrame(
            [[1, 2, 3], [4, 5, 6]],
            index=["a", "b"],
            columns=["x", "y", "z"],
            dtype=dtype,
        )
        encode_kwargs = {} if orient is None else {"orient": orient}
        assert (df.dtypes == dtype).all()

        output = ujson.decode(ujson.encode(df, **encode_kwargs))
        assert (df.dtypes == dtype).all()

        # Ensure proper DataFrame initialization.
        if orient == "split":
            dec = _clean_dict(output)
            output = DataFrame(**dec)
        else:
            output = DataFrame(output)

        # Corrections to enable DataFrame comparison.
        if orient == "values":
            df.columns = [0, 1, 2]
            df.index = [0, 1]
        elif orient == "records":
            df.index = [0, 1]
        elif orient == "index":
            df = df.T

        assert (df.dtypes == dtype).all()
        tm.assert_frame_equal(output, df)
//  [python]
def test_dataframe(self, orient):
        dtype = np.int64

        df = DataFrame(
            [[1, 2, 3], [4, 5, 6]],
            index=["a", "b"],
            columns=["x", "y", "z"],
            dtype=dtype,
        )
        encode_kwargs = {} if orient is None else {"orient": orient}
        assert (df.dtypes == dtype).all()

        output = ujson.decode(ujson.encode(df, **encode_kwargs))
        assert (df.dtypes == dtype).all()

        # Ensure proper DataFrame initialization.
        if orient == "split":
            dec = _clean_dict(output)
            output = DataFrame(**dec)
        else:
            output = DataFrame(output)

        # Corrections to enable DataFrame comparison.
        if orient == "values":
            df.columns = [0, 1, 2]
            df.index = [0, 1]
        elif orient == "records":
            df.index = [0, 1]
        elif orient == "index":
            df = df.transpose()

        assert (df.dtypes == dtype).all()
        tm.assert_frame_equal(output, df)
//  [python]
def test_corr_callable_method(self, datetime_series):
        # simple correlation example
        # returns 1 if exact equality, 0 otherwise
        my_corr = lambda a, b: 1. if (a == b).all() else 0.

        # simple example
        s1 = Series([1, 2, 3, 4, 5])
        s2 = Series([5, 4, 3, 2, 1])
        expected = 0
        tm.assert_almost_equal(
            s1.corr(s2, method=my_corr),
            expected)

        # full overlap
        tm.assert_almost_equal(datetime_series.corr(
            datetime_series, method=my_corr), 1.)

        # partial overlap
        tm.assert_almost_equal(datetime_series[:15].corr(
            datetime_series[5:], method=my_corr), 1.)

        # No overlap
        assert np.isnan(datetime_series[::2].corr(
            datetime_series[1::2], method=my_corr))

        # dataframe example
        df = pd.DataFrame([s1, s2])
        expected = pd.DataFrame([
            {0: 1., 1: 0}, {0: 0, 1: 1.}])
        tm.assert_almost_equal(
            df.T.corr(method=my_corr), expected)
//  [python]
def test_corr_callable_method(self, datetime_series):
        # simple correlation example
        # returns 1 if exact equality, 0 otherwise
        my_corr = lambda a, b: 1. if (a == b).all() else 0.

        # simple example
        s1 = Series([1, 2, 3, 4, 5])
        s2 = Series([5, 4, 3, 2, 1])
        expected = 0
        tm.assert_almost_equal(
            s1.corr(s2, method=my_corr),
            expected)

        # full overlap
        tm.assert_almost_equal(datetime_series.corr(
            datetime_series, method=my_corr), 1.)

        # partial overlap
        tm.assert_almost_equal(datetime_series[:15].corr(
            datetime_series[5:], method=my_corr), 1.)

        # No overlap
        assert np.isnan(datetime_series[::2].corr(
            datetime_series[1::2], method=my_corr))

        # dataframe example
        df = pd.DataFrame([s1, s2])
        expected = pd.DataFrame([
            {0: 1., 1: 0}, {0: 0, 1: 1.}])
        tm.assert_almost_equal(
            df.transpose().corr(method=my_corr), expected)
//  [python]
def test_transpose_copy_keyword(using_copy_on_write, copy, using_array_manager):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    result = df.T.copy(deep=copy)
    share_memory = using_copy_on_write or copy is False or copy is None
    share_memory = share_memory and not using_array_manager

    if share_memory:
        assert np.shares_memory(get_array(df, "a"), get_array(result, 0))
    else:
        assert not np.shares_memory(get_array(df, "a"), get_array(result, 0))
//  [python]
def test_transpose_copy_keyword(using_copy_on_write, copy, using_array_manager):
    df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    result = df.transpose(copy=copy)
    share_memory = using_copy_on_write or copy is False or copy is None
    share_memory = share_memory and not using_array_manager

    if share_memory:
        assert np.shares_memory(get_array(df, "a"), get_array(result, 0))
    else:
        assert not np.shares_memory(get_array(df, "a"), get_array(result, 0))
//  [python]
def test_xs_multiindex(using_copy_on_write, using_array_manager, key, level, axis):
    arr = np.arange(18).reshape(6, 3)
    index = MultiIndex.from_product([["l1", "l2"], [1, 2, 3]], names=["lev1", "lev2"])
    df = DataFrame(arr, index=index, columns=list("abc"))
    if axis == 1:
        df = df.T.copy()
    df_orig = df.copy()

    result = df.xs(key, level=level, axis=axis)

    if level == 0:
        assert np.shares_memory(
            get_array(df, df.columns[0]), get_array(result, result.columns[0])
        )

    warn = (
        SettingWithCopyWarning
        if not using_copy_on_write and not using_array_manager
        else None
    )
    with pd.option_context("chained_assignment", "warn"):
        with tm.assert_produces_warning(warn):
            result.iloc[0, 0] = 0

    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_xs_multiindex(using_copy_on_write, using_array_manager, key, level, axis):
    arr = np.arange(18).reshape(6, 3)
    index = MultiIndex.from_product([["l1", "l2"], [1, 2, 3]], names=["lev1", "lev2"])
    df = DataFrame(arr, index=index, columns=list("abc"))
    if axis == 1:
        df = df.transpose().copy()
    df_orig = df.copy()

    result = df.xs(key, level=level, axis=axis)

    if level == 0:
        assert np.shares_memory(
            get_array(df, df.columns[0]), get_array(result, result.columns[0])
        )

    warn = (
        SettingWithCopyWarning
        if not using_copy_on_write and not using_array_manager
        else None
    )
    with pd.option_context("chained_assignment", "warn"):
        with tm.assert_produces_warning(warn):
            result.iloc[0, 0] = 0

    tm.assert_frame_equal(df, df_orig)
//  [python]
def test_transpose(using_copy_on_write, copy, using_array_manager):
    df = DataFrame({"a": [1, 2, 3], "b": 1})
    df_orig = df.copy()
    result = df.T.copy(deep=copy)

    if not copy and not using_array_manager or using_copy_on_write:
        assert np.shares_memory(get_array(df, "a"), get_array(result, 0))
    else:
        assert not np.shares_memory(get_array(df, "a"), get_array(result, 0))

    result.iloc[0, 0] = 100
    if using_copy_on_write:
        tm.assert_frame_equal(df, df_orig)
//  [python]
def test_transpose(using_copy_on_write, copy, using_array_manager):
    df = DataFrame({"a": [1, 2, 3], "b": 1})
    df_orig = df.copy()
    result = df.transpose(copy=copy)

    if not copy and not using_array_manager or using_copy_on_write:
        assert np.shares_memory(get_array(df, "a"), get_array(result, 0))
    else:
        assert not np.shares_memory(get_array(df, "a"), get_array(result, 0))

    result.iloc[0, 0] = 100
    if using_copy_on_write:
        tm.assert_frame_equal(df, df_orig)
//  [python]
def test_transpose(data):
    modin_df = pd.DataFrame(data)
    pandas_df = pandas.DataFrame(data)

    df_equals(modin_df.T, pandas_df.T)
    df_equals(modin_df.T, pandas_df.T)

    # Test for map across full axis for select indices
    df_equals(modin_df.T.dropna(), pandas_df.T.dropna())
    # Test for map across full axis
    df_equals(modin_df.T.nunique(), pandas_df.T.nunique())
    # Test for map across blocks
    df_equals(modin_df.T.notna(), pandas_df.T.notna())
//  [python]
def test_transpose(data):
    modin_df = pd.DataFrame(data)
    pandas_df = pandas.DataFrame(data)

    df_equals(modin_df.T, pandas_df.T)
    df_equals(modin_df.transpose(), pandas_df.transpose())

    # Test for map across full axis for select indices
    df_equals(modin_df.T.dropna(), pandas_df.T.dropna())
    # Test for map across full axis
    df_equals(modin_df.T.nunique(), pandas_df.T.nunique())
    # Test for map across blocks
    df_equals(modin_df.T.notna(), pandas_df.T.notna())
//  [python]
def dec_emds(series, dec_type='EMD'):
    '''
    时间序列信号分解，基于emd的方法（使用EMD-signal库）
    series，时间序列信号数据，pd.Series
    dec_type，采用的分解算法类型，可选'EMD'、'EEMD'和'CEEMDAN'三种
    返回modes，分解之后的成分表，pd.DataFrame格式，每列代表一个成分，
    modes中第一列为最高频成分，倒数第二列为最低频成分，最后一列为分解残差

    '''

    if dec_type == 'EMD':
        method = PyEMD.EMD()
    elif dec_type == 'EEMD':
        method = PyEMD.EEMD()
    elif dec_type == 'CEEMDAN':
        method = PyEMD.CEEMDAN()
    else:
        raise ValueError('分解方法请选择EMD、EEMD和CEEMDAN中的一种！')

    modes = method(np.array(series))
    modes = pd.DataFrame(modes.T)
    cols = ['imf_' + str(k) for k in range(1, modes.shape[1]+1)]
    modes.columns = cols
    modes.set_index(series.index, inplace=True)
    modes['dec_res'] = series-modes.T.sum()

    return modes
//  [python]
def dec_emds(series, dec_type='EMD'):
    '''
    时间序列信号分解，基于emd的方法（使用EMD-signal库）
    series，时间序列信号数据，pd.Series
    dec_type，采用的分解算法类型，可选'EMD'、'EEMD'和'CEEMDAN'三种
    返回modes，分解之后的成分表，pd.DataFrame格式，每列代表一个成分，
    modes中第一列为最高频成分，倒数第二列为最低频成分，最后一列为分解残差

    '''

    if dec_type == 'EMD':
        method = PyEMD.EMD()
    elif dec_type == 'EEMD':
        method = PyEMD.EEMD()
    elif dec_type == 'CEEMDAN':
        method = PyEMD.CEEMDAN()
    else:
        raise ValueError('分解方法请选择EMD、EEMD和CEEMDAN中的一种！')

    modes = method(np.array(series))
    modes = pd.DataFrame(modes.transpose())
    cols = ['imf_' + str(k) for k in range(1, modes.shape[1]+1)]
    modes.columns = cols
    modes.set_index(series.index, inplace=True)
    modes['dec_res'] = series-modes.transpose().sum()

    return modes
//  [python]
def compute_bng_contig_support(agp_layout):

    supported = []
    unsupported = []
    contig_names = []

    contig_to_scaffold = col.defaultdict(list)
    scaffold_to_contig = col.defaultdict(list)

    unsupported_broken = col.Counter()

    for idx, row in agp_layout.iterrows():
        if row['comp_type'] == 'N':
            continue
        else:
            contig_name = row['comp_name_OR_gap_length']
            if 'subseq' in contig_name:
                contig_name = contig_name.split('_subseq_')[0]

            if 'Super-Scaffold' not in row['object_name']:
                # unscaffolded sequence
                if 'subseq' in row['comp_name_OR_gap_length']:
                    # happens that multiple fragments of a contig
                    # appear as unsupported / unscaffolded for
                    # whatever reason
                    unsupported_broken[contig_name] += 1

                supported.append(0)
                unsupported.append(int(row['comp_end_OR_linkage']))
            else:
                contig_to_scaffold[contig_name].append(row['object_name'])
                scaffold_to_contig[row['object_name']].append(contig_name)

                supported.append(int(row['comp_end_OR_linkage']))
                unsupported.append(0)

            contig_names.append(contig_name)

    df = pd.DataFrame(
        [contig_names, supported, unsupported],
        index=[
            'contig_name',
            'BNG_supported',
            'BNG_unsupported'
        ]
    ).T

    contig_counts = df['contig_name'].value_counts()
    df = df.groupby('contig_name')[['BNG_supported', 'BNG_unsupported']].sum()
    df['contig_name'] = df.index.values
    df.reset_index(drop=True, inplace=True)
    df['contig_breaks'] = df['contig_name'].apply(lambda x: contig_counts[x] - 1)

    # no clue why, but some contigs are broken despite being unsupported
    # cluster10_contig_270_subseq_1:79636_obj
    # cluster10_contig_270_subseq_79637:120374_obj
    # ---> cluster10_contig_270    120374
    # so fix that here
    df.loc[df['BNG_supported'] == 0, 'contig_breaks'] = 0

    # now fix cases where a single contig has several BNG unsupported
    # fragments, which would otherwise be counted multiple times
    for ctg, broken_count in unsupported_broken.most_common():
        if broken_count < 2:
            break
        # count several "unsupported" fragments as one
        unsupported_breaks = broken_count - 1
        counted_breaks = int(df.loc[df['contig_name'] == ctg, 'contig_breaks'])
        if counted_breaks > 0:
            # avoids clash/duplicates together with first fix
            df.loc[df['contig_name'] == ctg, 'contig_breaks'] -= unsupported_breaks

    return df, contig_to_scaffold, scaffold_to_contig
//  [python]
def compute_bng_contig_support(agp_layout):

    supported = []
    unsupported = []
    contig_names = []

    contig_to_scaffold = col.defaultdict(list)
    scaffold_to_contig = col.defaultdict(list)

    unsupported_broken = col.Counter()

    for idx, row in agp_layout.iterrows():
        if row['comp_type'] == 'N':
            continue
        else:
            contig_name = row['comp_name_OR_gap_length']
            if 'subseq' in contig_name:
                contig_name = contig_name.split('_subseq_')[0]

            if 'Super-Scaffold' not in row['object_name']:
                # unscaffolded sequence
                if 'subseq' in row['comp_name_OR_gap_length']:
                    # happens that multiple fragments of a contig
                    # appear as unsupported / unscaffolded for
                    # whatever reason
                    unsupported_broken[contig_name] += 1

                supported.append(0)
                unsupported.append(int(row['comp_end_OR_linkage']))
            else:
                contig_to_scaffold[contig_name].append(row['object_name'])
                scaffold_to_contig[row['object_name']].append(contig_name)

                supported.append(int(row['comp_end_OR_linkage']))
                unsupported.append(0)

            contig_names.append(contig_name)

    df = pd.DataFrame(
        [contig_names, supported, unsupported],
        index=[
            'contig_name',
            'BNG_supported',
            'BNG_unsupported'
        ]
    )
    df = df.transpose()

    contig_counts = df['contig_name'].value_counts()
    df = df.groupby('contig_name')[['BNG_supported', 'BNG_unsupported']].sum()
    df['contig_name'] = df.index.values
    df.reset_index(drop=True, inplace=True)
    df['contig_breaks'] = df['contig_name'].apply(lambda x: contig_counts[x] - 1)

    # no clue why, but some contigs are broken despite being unsupported
    # cluster10_contig_270_subseq_1:79636_obj
    # cluster10_contig_270_subseq_79637:120374_obj
    # ---> cluster10_contig_270    120374
    # so fix that here
    df.loc[df['BNG_supported'] == 0, 'contig_breaks'] = 0

    # now fix cases where a single contig has several BNG unsupported
    # fragments, which would otherwise be counted multiple times
    for ctg, broken_count in unsupported_broken.most_common():
        if broken_count < 2:
            break
        # count several "unsupported" fragments as one
        unsupported_breaks = broken_count - 1
        counted_breaks = int(df.loc[df['contig_name'] == ctg, 'contig_breaks'])
        if counted_breaks > 0:
            # avoids clash/duplicates together with first fix
            df.loc[df['contig_name'] == ctg, 'contig_breaks'] -= unsupported_breaks

    return df, contig_to_scaffold, scaffold_to_contig
//  [python]
def semivarf(Kdata,Xdata,Ydata,Zdata):
    K=Kdata.reshape(np.size(Kdata),-1)
    X=Xdata.reshape(np.size(Xdata),-1)
    Y=Ydata.reshape(np.size(Ydata),-1)
    Z=Zdata.reshape(np.size(Zdata),-1)
    loc=np.append(X,Y,axis=1)
    loc=np.append(loc,Z,axis=1)
    dis=np.zeros([len(K),len(K)])
    for i in range(len(K)):
        for j in range(i,len(K)):
            dis[i,j]=dist(loc[i,:],loc[j,:])
    semivar=np.zeros([len(K),len(K)])
    for i in range(len(K)):
        for j in range(i,len(K)):
            semivar[i,j]=0.5*var(K[i],K[j])
    semivar=semivar[np.where(dis != 0)]
    dis=dis[np.where(dis != 0)]
    for i in range(len(dis)):
        dis[i]=round(dis[i],0)
    semivar=semivar[np.where(dis != 0)]
    dis=dis[np.where(dis != 0)]
    
    df = pd.DataFrame([dis,semivar])
    df = df.T
    mean = df.groupby(0).mean()
    dis = np.array(mean.index.values)
    semivar = mean.values[:,0]
    return dis, semivar
//  [python]
def semivarf(Kdata,Xdata,Ydata,Zdata):
    K=Kdata.reshape(np.size(Kdata),-1)
    X=Xdata.reshape(np.size(Xdata),-1)
    Y=Ydata.reshape(np.size(Ydata),-1)
    Z=Zdata.reshape(np.size(Zdata),-1)
    loc=np.append(X,Y,axis=1)
    loc=np.append(loc,Z,axis=1)
    dis=np.zeros([len(K),len(K)])
    for i in range(len(K)):
        for j in range(i,len(K)):
            dis[i,j]=dist(loc[i,:],loc[j,:])
    semivar=np.zeros([len(K),len(K)])
    for i in range(len(K)):
        for j in range(i,len(K)):
            semivar[i,j]=0.5*var(K[i],K[j])
    semivar=semivar[np.where(dis != 0)]
    dis=dis[np.where(dis != 0)]
    for i in range(len(dis)):
        dis[i]=round(dis[i],0)
    semivar=semivar[np.where(dis != 0)]
    dis=dis[np.where(dis != 0)]
    
    df = pd.DataFrame([dis,semivar])
    df = df.transpose()
    mean = df.groupby(0).mean()
    dis = np.array(mean.index.values)
    semivar = mean.values[:,0]
    return dis, semivar
//  [python]
def test_dataframe_transpose_category(num_cols, num_rows):
    pdf = pd.DataFrame()

    for i in range(num_cols):
        colname = string.ascii_lowercase[i]
        data = pd.Series(list(string.ascii_lowercase), dtype="category")
        data = data.sample(num_rows, replace=True).reset_index(drop=True)
        pdf[colname] = data

    gdf = cudf.DataFrame.from_pandas(pdf)

    got_function = gdf.T
    got_property = gdf.T

    expect = pdf.T

    assert_eq(expect, got_function.to_pandas())
    assert_eq(expect, got_property.to_pandas())
//  [python]
def test_dataframe_transpose_category(num_cols, num_rows):
    pdf = pd.DataFrame()

    for i in range(num_cols):
        colname = string.ascii_lowercase[i]
        data = pd.Series(list(string.ascii_lowercase), dtype="category")
        data = data.sample(num_rows, replace=True).reset_index(drop=True)
        pdf[colname] = data

    gdf = cudf.DataFrame.from_pandas(pdf)

    got_function = gdf.transpose()
    got_property = gdf.T

    expect = pdf.transpose()

    assert_eq(expect, got_function.to_pandas())
    assert_eq(expect, got_property.to_pandas())
//  [python]
def test_transpose(self):
        # TODO: what if with random index?
        pdf1 = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, columns=["col1", "col2"])
        psdf1 = ps.from_pandas(pdf1)

        pdf2 = pd.DataFrame(
            data={"score": [9, 8], "kids": [0, 0], "age": [12, 22]},
            columns=["score", "kids", "age"],
        )
        psdf2 = ps.from_pandas(pdf2)

        self.assert_eq(pdf1.T.sort_index(), psdf1.T.sort_index())
        self.assert_eq(pdf2.T.sort_index(), psdf2.T.sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf1.T.sort_index(), psdf1.T.sort_index())

            self.assert_eq(pdf2.T.sort_index(), psdf2.T.sort_index())

        pdf3 = pd.DataFrame(
            {
                ("cg1", "a"): [1, 2, 3],
                ("cg1", "b"): [4, 5, 6],
                ("cg2", "c"): [7, 8, 9],
                ("cg3", "d"): [9, 9, 9],
            },
            index=pd.MultiIndex.from_tuples([("rg1", "x"), ("rg1", "y"), ("rg2", "z")]),
        )
        psdf3 = ps.from_pandas(pdf3)

        self.assert_eq(pdf3.T.sort_index(), psdf3.T.sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf3.T.sort_index(), psdf3.T.sort_index())
//  [python]
def test_transpose(self):
        # TODO: what if with random index?
        pdf1 = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, columns=["col1", "col2"])
        psdf1 = ps.from_pandas(pdf1)

        pdf2 = pd.DataFrame(
            data={"score": [9, 8], "kids": [0, 0], "age": [12, 22]},
            columns=["score", "kids", "age"],
        )
        psdf2 = ps.from_pandas(pdf2)

        self.assert_eq(pdf1.transpose().sort_index(), psdf1.transpose().sort_index())
        self.assert_eq(pdf2.transpose().sort_index(), psdf2.transpose().sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf1.transpose().sort_index(), psdf1.transpose().sort_index())

            self.assert_eq(pdf2.transpose().sort_index(), psdf2.transpose().sort_index())

        pdf3 = pd.DataFrame(
            {
                ("cg1", "a"): [1, 2, 3],
                ("cg1", "b"): [4, 5, 6],
                ("cg2", "c"): [7, 8, 9],
                ("cg3", "d"): [9, 9, 9],
            },
            index=pd.MultiIndex.from_tuples([("rg1", "x"), ("rg1", "y"), ("rg2", "z")]),
        )
        psdf3 = ps.from_pandas(pdf3)

        self.assert_eq(pdf3.transpose().sort_index(), psdf3.transpose().sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf3.transpose().sort_index(), psdf3.transpose().sort_index())
//  [python]
def Column_information(self,data):
    
        data_info = pd.DataFrame(
                                columns=['No of observation',
                                        'No of Variables',
                                        'No of Numerical Variables',
                                        'No of Factor Variables',
                                        'No of Categorical Variables',
                                        'No of Logical Variables',
                                        'No of Date Variables',
                                        'No of zero variance variables'])


        data_info.loc[0,'No of observation'] = data.shape[0]
        data_info.loc[0,'No of Variables'] = data.shape[1]
        data_info.loc[0,'No of Numerical Variables'] = data._get_numeric_data().shape[1]
        data_info.loc[0,'No of Factor Variables'] = data.select_dtypes(include='category').shape[1]
        data_info.loc[0,'No of Logical Variables'] = data.select_dtypes(include='bool').shape[1]
        data_info.loc[0,'No of Categorical Variables'] = data.select_dtypes(include='object').shape[1]
        data_info.loc[0,'No of Date Variables'] = data.select_dtypes(include='datetime64').shape[1]
        data_info.loc[0,'No of zero variance variables'] = data.loc[:,data.apply(pd.Series.nunique)==1].shape[1]

        data_info =data_info.T
        data_info.columns=['value']
        data_info['value'] = data_info['value'].astype(int)


        return data_info
//  [python]
def Column_information(self,data):
    
        data_info = pd.DataFrame(
                                columns=['No of observation',
                                        'No of Variables',
                                        'No of Numerical Variables',
                                        'No of Factor Variables',
                                        'No of Categorical Variables',
                                        'No of Logical Variables',
                                        'No of Date Variables',
                                        'No of zero variance variables'])


        data_info.loc[0,'No of observation'] = data.shape[0]
        data_info.loc[0,'No of Variables'] = data.shape[1]
        data_info.loc[0,'No of Numerical Variables'] = data._get_numeric_data().shape[1]
        data_info.loc[0,'No of Factor Variables'] = data.select_dtypes(include='category').shape[1]
        data_info.loc[0,'No of Logical Variables'] = data.select_dtypes(include='bool').shape[1]
        data_info.loc[0,'No of Categorical Variables'] = data.select_dtypes(include='object').shape[1]
        data_info.loc[0,'No of Date Variables'] = data.select_dtypes(include='datetime64').shape[1]
        data_info.loc[0,'No of zero variance variables'] = data.loc[:,data.apply(pd.Series.nunique)==1].shape[1]

        data_info =data_info.transpose()
        data_info.columns=['value']
        data_info['value'] = data_info['value'].astype(int)


        return data_info
//  [python]
def test_iteritems(self):
        pser = pd.Series(["A", "B", "C"])
        psser = ps.from_pandas(pser)

        for (p_name, p_items), (k_name, k_items) in zip(pser.iteritems(), psser.iteritems()):
            self.assert_eq(p_name, k_name)
            self.assert_eq(p_items, k_items)
//  [python]
def test_iteritems(self):
        pser = pd.Series(["A", "B", "C"])
        psser = ps.from_pandas(pser)

        for (p_name, p_items), (k_name, k_items) in zip(pser.items(), psser.items()):
            self.assert_eq(p_name, k_name)
            self.assert_eq(p_items, k_items)
//  [python]
def test_transpose(self):
        # TODO: what if with random index?
        pdf1 = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, columns=["col1", "col2"])
        kdf1 = ks.from_pandas(pdf1)

        pdf2 = pd.DataFrame(
            data={"score": [9, 8], "kids": [0, 0], "age": [12, 22]},
            columns=["score", "kids", "age"],
        )
        kdf2 = ks.from_pandas(pdf2)

        self.assert_eq(pdf1.T.sort_index(), kdf1.T.sort_index())
        self.assert_eq(pdf2.T.sort_index(), kdf2.T.sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf1.T.sort_index(), kdf1.T.sort_index())

            self.assert_eq(pdf2.T.sort_index(), kdf2.T.sort_index())

        pdf3 = pd.DataFrame(
            {
                ("cg1", "a"): [1, 2, 3],
                ("cg1", "b"): [4, 5, 6],
                ("cg2", "c"): [7, 8, 9],
                ("cg3", "d"): [9, 9, 9],
            },
            index=pd.MultiIndex.from_tuples([("rg1", "x"), ("rg1", "y"), ("rg2", "z")]),
        )
        kdf3 = ks.from_pandas(pdf3)

        self.assert_eq(pdf3.T.sort_index(), kdf3.T.sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf3.T.sort_index(), kdf3.T.sort_index())
//  [python]
def test_transpose(self):
        # TODO: what if with random index?
        pdf1 = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]}, columns=["col1", "col2"])
        kdf1 = ks.from_pandas(pdf1)

        pdf2 = pd.DataFrame(
            data={"score": [9, 8], "kids": [0, 0], "age": [12, 22]},
            columns=["score", "kids", "age"],
        )
        kdf2 = ks.from_pandas(pdf2)

        self.assert_eq(pdf1.transpose().sort_index(), kdf1.transpose().sort_index())
        self.assert_eq(pdf2.transpose().sort_index(), kdf2.transpose().sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf1.transpose().sort_index(), kdf1.transpose().sort_index())

            self.assert_eq(pdf2.transpose().sort_index(), kdf2.transpose().sort_index())

        pdf3 = pd.DataFrame(
            {
                ("cg1", "a"): [1, 2, 3],
                ("cg1", "b"): [4, 5, 6],
                ("cg2", "c"): [7, 8, 9],
                ("cg3", "d"): [9, 9, 9],
            },
            index=pd.MultiIndex.from_tuples([("rg1", "x"), ("rg1", "y"), ("rg2", "z")]),
        )
        kdf3 = ks.from_pandas(pdf3)

        self.assert_eq(pdf3.transpose().sort_index(), kdf3.transpose().sort_index())

        with option_context("compute.max_rows", None):
            self.assert_eq(pdf3.transpose().sort_index(), kdf3.transpose().sort_index())
//  [python]
def test_df_transpose_repeated_uses_cache():
    bf_df = dataframe.DataFrame([[1, 2.5], [2, 3.5]])
    pd_df = pandas.DataFrame([[1, 2.5], [2, 3.5]])
    # Transposing many times so that operation will fail from complexity if not using cache
    for i in range(10):
        # Cache still works even with simple scalar binop
        bf_df = bf_df.T + i
        pd_df = pd_df.T + i

    pd.testing.assert_frame_equal(
        pd_df, bf_df.to_pandas(), check_dtype=False, check_index_type=False
    )
//  [python]
def test_df_transpose_repeated_uses_cache():
    bf_df = dataframe.DataFrame([[1, 2.5], [2, 3.5]])
    pd_df = pandas.DataFrame([[1, 2.5], [2, 3.5]])
    # Transposing many times so that operation will fail from complexity if not using cache
    for i in range(10):
        # Cache still works even with simple scalar binop
        bf_df = bf_df.transpose() + i
        pd_df = pd_df.transpose() + i

    pd.testing.assert_frame_equal(
        pd_df, bf_df.to_pandas(), check_dtype=False, check_index_type=False
    )
//  [python]
def testDataFrame(self):
        df = DataFrame([[1, 2, 3], [4, 5, 6]], index=[
                       'a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df)))
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split")))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="records")))
        outp.index = df.index
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="values")))
        outp.index = df.index
        self.assertTrue((df.values == outp.values).all())

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index")))
        self.assertTrue((df.T == outp).values.all())
        tm.assert_index_equal(df.T.columns, outp.columns)
        tm.assert_index_equal(df.T.index, outp.index)
//  [python]
def testDataFrame(self):
        df = DataFrame([[1, 2, 3], [4, 5, 6]], index=[
                       'a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df)))
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split")))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="records")))
        outp.index = df.index
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="values")))
        outp.index = df.index
        self.assertTrue((df.values == outp.values).all())

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index")))
        self.assertTrue((df.transpose() == outp).values.all())
        tm.assert_index_equal(df.transpose().columns, outp.columns)
        tm.assert_index_equal(df.transpose().index, outp.index)
//  [python]
def testDataFrameNumpy(self):
        df = DataFrame([[1, 2, 3], [4, 5, 6]], index=[
                       'a', 'b'], columns=['x', 'y', 'z'])

        # column indexed
        outp = DataFrame(ujson.decode(ujson.encode(df), numpy=True))
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        dec = _clean_dict(ujson.decode(ujson.encode(df, orient="split"),
                                       numpy=True))
        outp = DataFrame(**dec)
        self.assertTrue((df == outp).values.all())
        tm.assert_index_equal(df.columns, outp.columns)
        tm.assert_index_equal(df.index, outp.index)

        outp = DataFrame(ujson.decode(ujson.encode(df, orient="index"),
                                      numpy=True))
        self.assertTrue((df.T == outp).values.all())
        tm.assert_index_equal(df.T.columns, outp.columns)
        tm.assert_index_equal(df.T.index, outp.index)