Created
June 15, 2020 15:18
-
-
Save sllynn/9eb3e37449a0614806ccafde676f8052 to your computer and use it in GitHub Desktop.
Pandas UDF for converting Excel dates to Spark timestamps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pandas_udf("timestamp", PandasUDFType.SCALAR) | |
def from_xltime(x): | |
import pandas as pd | |
import datetime as dt | |
return (pd.TimedeltaIndex(x, unit='d') + dt.datetime(1899,12,30)).to_series() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment