-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When pandas load data from excel, some date columns will load as datetime object.
Excel content:
| date | count |
|---|---|
| 2019/1/1 | 1 |
| 2019/1/2 | 1 |
| 2019/1/3 | 1 |
| 2019/1/4 | 1 |
| 2019/1/5 | 1 |
| 2019/1/6 | 1 |
pip install pandas openpyxlimport pandas
# from json import dumps
def main():
df = pandas.read_excel('date.xlsx')
print(df)
print(df.dtypes)
# d = dumps(df.to_dict(orient='split')) # will crash and report 'TypeError: Object of type Timestamp is not JSON serializable'
if __name__ == "__main__":
main()Currently context api use to_json instead of to_dict to avoid this error.
to_json will transform date to epoch milliseconds(default) or ISO8601(iso option) format. The default ISO 8601 format is 2019-01-02T00:00:00.000.
Target:
- It should be better use local timezone or what we see in Excel(the actually value is float).
- Add datetime test case
Metadata
Metadata
Assignees
Labels
No labels