MCPcopy Create free account
hub / github.com/dask/dask / test_datetimes

Function test_datetimes

dask/dataframe/io/tests/test_sql.py:349–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

347
348
349def test_datetimes():
350 import datetime
351
352 now = datetime.datetime.now()
353 d = datetime.timedelta(seconds=1)
354 df = pd.DataFrame(
355 {"a": list("ghjkl"), "b": [now + i * d for i in range(2, -3, -1)]}
356 )
357 with tmpfile() as f:
358 uri = f"sqlite:///{f}"
359 df.to_sql("test", uri, index=False, if_exists="replace")
360 data = read_sql_table("test", uri, npartitions=2, index_col="b")
361 assert data.index.dtype.kind == "M"
362 assert data.divisions[0] == df.b.min()
363 df2 = df.set_index("b")
364 assert_eq(
365 data.map_partitions(lambda x: x.sort_index()),
366 df2.sort_index(),
367 check_dtype=False,
368 )
369
370
371def test_extra_connection_engine_keywords(caplog, db):

Callers

nothing calls this directly

Calls 7

set_indexMethod · 0.95
tmpfileFunction · 0.90
read_sql_tableFunction · 0.90
assert_eqFunction · 0.90
to_sqlMethod · 0.80
minMethod · 0.45
map_partitionsMethod · 0.45

Tested by

no test coverage detected