Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pandas/_testing/compat.py: 40%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1""" 

2Helpers for sharing tests between DataFrame/Series 

3""" 

4from pandas._typing import DtypeObj 

5 

6from pandas import DataFrame 

7 

8 

9def get_dtype(obj) -> DtypeObj: 

10 if isinstance(obj, DataFrame): 

11 # Note: we are assuming only one column 

12 return obj.dtypes.iat[0] 

13 else: 

14 return obj.dtype 

15 

16 

17def get_obj(df: DataFrame, klass): 

18 """ 

19 For sharing tests using frame_or_series, either return the DataFrame 

20 unchanged or return it's first column as a Series. 

21 """ 

22 if klass is DataFrame: 

23 return df 

24 return df._ixs(0, axis=1)