Download valley/lib/python3.10/site-packages/pandas/_testing/compat.py from ZTWHHH/envs_2: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/valley/lib/python3.10/site-packages/pandas/_testing/compat.py
- Command line
-
hf download hf://datasets/ZTWHHH/envs_2/valley/lib/python3.10/site-packages/pandas/_testing/compat.py
-
curl -L -o compat.py https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/valley/lib/python3.10/site-packages/pandas/_testing/compat.py
658 Bytes
| """ | |
| Helpers for sharing tests between DataFrame/Series | |
| """ | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| from pandas import DataFrame | |
| if TYPE_CHECKING: | |
| from pandas._typing import DtypeObj | |
| def get_dtype(obj) -> DtypeObj: | |
| if isinstance(obj, DataFrame): | |
| # Note: we are assuming only one column | |
| return obj.dtypes.iat[0] | |
| else: | |
| return obj.dtype | |
| def get_obj(df: DataFrame, klass): | |
| """ | |
| For sharing tests using frame_or_series, either return the DataFrame | |
| unchanged or return it's first column as a Series. | |
| """ | |
| if klass is DataFrame: | |
| return df | |
| return df._ixs(0, axis=1) | |