def test_pandas_to_table():
    try:
        import pandas as pd

        df = pd.DataFrame(dict(a=[1,2,3], b=["c", "d", "e"]))
        schema = Schema(name="Baz", parent="syn12345", columns=as_table_columns(df))
        print("\n", df, "\n\n")

        ## A dataframe with no row id and version
        table = Table(schema, df)

        for i, row in enumerate(table):
            print(row)
            assert row[0]==(i+1)
            assert row[1]==["c", "d", "e"][i]

        assert len(table)==3

        ## If includeRowIdAndRowVersion=True, include empty row id an versions
        ## ROW_ID,ROW_VERSION,a,b
        ## ,,1,c
        ## ,,2,d
        ## ,,3,e
        table = Table(schema, df, includeRowIdAndRowVersion=True)
        for i, row in enumerate(table):
            print(row)
            assert row[0] is None
            assert row[1] is None
            assert row[2]==(i+1)

        ## A dataframe with no row id and version
        df = pd.DataFrame(index=["1_7","2_7","3_8"], data=dict(a=[100,200,300], b=["c", "d", "e"]))
        print("\n", df, "\n\n")

        table = Table(schema, df)
        for i, row in enumerate(table):
            print(row)
            assert row[0]==["1","2","3"][i]
            assert row[1]==["7","7","8"][i]
            assert row[2]==(i+1)*100
            assert row[3]==["c", "d", "e"][i]

        ## A dataframe with row id and version in columns
        df = pd.DataFrame(dict(ROW_ID=["0","1","2"], ROW_VERSION=["8","9","9"], a=[100,200,300], b=["c", "d", "e"]))
        print("\n", df, "\n\n")

        table = Table(schema, df)
        for i, row in enumerate(table):
            print(row)
            assert row[0]==["0","1","2"][i]
            assert row[1]==["8","9","9"][i]
            assert row[2]==(i+1)*100
            assert row[3]==["c", "d", "e"][i]

    except __HOLE__ as e1:
        sys.stderr.write('Pandas is apparently not installed, skipping test_pandas_to_table.\n\n')
dataset/ETHPy150Open Sage-Bionetworks/synapsePythonClient/tests/unit/unit_test_tables.py/test_pandas_to_table