Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add datetime as the equivalent python type to TimestampType #957

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions databricks/koalas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from distutils.version import LooseVersion
import inspect
from io import BytesIO
from datetime import datetime, timedelta

import matplotlib
matplotlib.use('agg')
Expand Down Expand Up @@ -471,6 +472,15 @@ def test_map(self):
repr(kser.map(d)),
repr(pser.map(d).rename(0)))

def tomorrow(date) -> datetime:
return date + timedelta(days=1)

pser = pd.Series([datetime(2019, 10, 24)])
kser = ks.from_pandas(pser)
self.assertEqual(
repr(kser.map(tomorrow)),
repr(pser.map(tomorrow).rename(0)))

def test_add_prefix(self):
pser = pd.Series([1, 2, 3, 4], name='0')
kser = ks.from_pandas(pser)
Expand Down
2 changes: 1 addition & 1 deletion databricks/koalas/typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _to_stype(tpe) -> X:
types.LongType(): [np.int64, 'int64', 'long', 'bigint'],
types.FloatType(): [float, 'float', np.float],
types.DoubleType(): [np.float64, 'float64', 'double'],
types.TimestampType(): [np.datetime64],
types.TimestampType(): [datetime.datetime, np.datetime64],
types.DateType(): [datetime.date],
types.BooleanType(): [bool, 'boolean', 'bool', np.bool],
types.ArrayType(types.StringType()): []
Expand Down