()
| 39 | |
| 40 | |
| 41 | def test_convert_axis(): |
| 42 | def _test_df(df: pd.DataFrame): |
| 43 | convert_axis(df) |
| 44 | assert df.columns.nlevels == 1 |
| 45 | assert df.index.nlevels == 1 |
| 46 | assert isinstance(df.index, pd.RangeIndex) |
| 47 | |
| 48 | # ontario systems df - as per https://github.com/datapane/datapane-hosted/issues/762 |
| 49 | data = { |
| 50 | "Jan": pd.DataFrame(columns=["Market", "Units Sold", "New Customers"], data=[["East", 14, 1]]).set_index( |
| 51 | "Market" |
| 52 | ), |
| 53 | "Feb": pd.DataFrame(columns=["Market", "Units Sold", "New Customers"], data=[["East", 45, 6]]).set_index( |
| 54 | "Market" |
| 55 | ), |
| 56 | } |
| 57 | df_o = pd.concat(data, axis=1) |
| 58 | _test_df(df_o) |
| 59 | |
| 60 | # pandas multiindex demo |
| 61 | index = pd.MultiIndex.from_tuples( |
| 62 | [("bird", "falcon"), ("bird", "parrot"), ("mammal", "lion"), ("mammal", "monkey")], names=["class", "name"] |
| 63 | ) |
| 64 | columns = pd.MultiIndex.from_tuples([("speed", "max"), ("species", "type")]) |
| 65 | df_m = pd.DataFrame([(389.0, "fly"), (24.0, "fly"), (80.5, "run"), (np.nan, "jump")], index=index, columns=columns) |
| 66 | _test_df(df_m) |
| 67 | |
| 68 | |
| 69 | def test_parse_categories_small(): |
nothing calls this directly
no test coverage detected