(self)
| 3210 | pa.Table.from_pandas(df) |
| 3211 | |
| 3212 | def test_strided_data_import(self): |
| 3213 | cases = [] |
| 3214 | |
| 3215 | columns = ['a', 'b', 'c'] |
| 3216 | N, K = 100, 3 |
| 3217 | random_numbers = np.random.randn(N, K).copy() * 100 |
| 3218 | |
| 3219 | numeric_dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8', |
| 3220 | 'f4', 'f8'] |
| 3221 | |
| 3222 | for type_name in numeric_dtypes: |
| 3223 | # Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning |
| 3224 | with warnings.catch_warnings(): |
| 3225 | warnings.simplefilter("ignore") |
| 3226 | cases.append(random_numbers.astype(type_name)) |
| 3227 | |
| 3228 | # strings |
| 3229 | cases.append(np.array([random_ascii(10) for i in range(N * K)], |
| 3230 | dtype=object) |
| 3231 | .reshape(N, K).copy()) |
| 3232 | |
| 3233 | # booleans |
| 3234 | boolean_objects = (np.array([True, False, True] * N, dtype=object) |
| 3235 | .reshape(N, K).copy()) |
| 3236 | |
| 3237 | # add some nulls, so dtype comes back as objects |
| 3238 | boolean_objects[5] = None |
| 3239 | cases.append(boolean_objects) |
| 3240 | |
| 3241 | cases.append(np.arange("2016-01-01T00:00:00.001", N * K, |
| 3242 | dtype='datetime64[ms]') |
| 3243 | .reshape(N, K).copy()) |
| 3244 | |
| 3245 | strided_mask = (random_numbers > 0).astype(bool)[:, 0] |
| 3246 | |
| 3247 | for case in cases: |
| 3248 | df = pd.DataFrame(case, columns=columns) |
| 3249 | col = df['a'] |
| 3250 | |
| 3251 | _check_pandas_roundtrip(df) |
| 3252 | _check_array_roundtrip(col) |
| 3253 | _check_array_roundtrip(col, mask=strided_mask) |
| 3254 | |
| 3255 | def test_all_nones(self): |
| 3256 | def _check_series(s): |
nothing calls this directly
no test coverage detected