Skip to content

[BUG] Timestamp is not JSON serializable #650

@AaronVerDow

Description

@AaronVerDow

Describe the bug
Timestamps are not being processed correctly, csv cannot be used.

Logs show: Error creating table component: Object of type Timestamp is not JSON serializable and 'LAST_UPDATED': Timestamp('2010-07-21 14:51:06')}]

Relevant logs:

2025-04-10 16:10:01,571 - preswald.interfaces.components - DEBUG - Processed Data (first 5 rows): [{'SEGMENTID': 1284, 'STREET': 'Chicago', 'DIRECTION': 'WB', 'FROM_STREET': 'Lake Shore Dr', 'TO_STREET': 'Michigan', 'LENGTH': 0.37, 'STREET_HEADING': 'E', 'COMMENTS': '', 'START_LONGITUDE': -87.617048, 'START_LATITUDE': 41.896936, 'END_LONGITUDE': -87.624241, 'END_LATITUDE': 41.896835, 'CURRENT_SPEED': -1, 'LAST_UPDATED': Timestamp('2011-08-10 00:00:00')}, {'SEGMENTID': 951, 'STREET': 'Washington', 'DIRECTION': 'WB', 'FROM_STREET': 'Kedzie', 'TO_STREET': 'Schraeder', 'LENGTH': 0.28, 'STREET_HEADING': 'W', 'COMMENTS': '', 'START_LONGITUDE': -87.7061691246, 'START_LATITUDE': 41.8829315251, 'END_LONGITUDE': -87.7117472865, 'END_LATITUDE': 41.8828184746, 'CURRENT_SPEED': -1, 'LAST_UPDATED': Timestamp('2010-07-21 14:51:00')}, {'SEGMENTID': 750, 'STREET': 'Elston', 'DIRECTION': 'SE', 'FROM_STREET': 'Milwaukee', 'TO_STREET': 'Austin', 'LENGTH': 0.33, 'STREET_HEADING': 'N', 'COMMENTS': '', 'START_LONGITUDE': -87.7832243493, 'START_LATITUDE': 41.9926646035, 'END_LONGITUDE': -87.7780730735, 'END_LATITUDE': 41.9899051234, 'CURRENT_SPEED': -1, 'LAST_UPDATED': Timestamp('2010-07-21 14:51:10')}, {'SEGMENTID': 1164, 'STREET': 'Harlem', 'DIRECTION': 'SB', 'FROM_STREET': 'Ogden', 'TO_STREET': 'Pershing', 'LENGTH': 0.173022844032, 'STREET_HEADING': 'S', 'COMMENTS': 'Outside City Limits', 'START_LONGITUDE': -87.802921906, 'START_LATITUDE': 41.8237508093, 'END_LONGITUDE': -87.8030252034, 'END_LATITUDE': 41.8212448346, 'CURRENT_SPEED': -1, 'LAST_UPDATED': Timestamp('2010-07-21 14:51:15')}, {'SEGMENTID': 1122, 'STREET': '127th', 'DIRECTION': 'EB', 'FROM_STREET': 'Western', 'TO_STREET': 'I-57 Expy', 'LENGTH': 0.907892221885, 'STREET_HEADING': 'W', 'COMMENTS': 'Outside City Limits', 'START_LONGITUDE': -87.6800769707, 'START_LATITUDE': 41.6625116506, 'END_LONGITUDE': -87.6625398368, 'END_LATITUDE': 41.6628497334, 'CURRENT_SPEED': -1, 'LAST_UPDATED': Timestamp('2010-07-21 14:51:06')}]
2025-04-10 16:10:01,572 - preswald.interfaces.components - ERROR - Error creating table component: Object of type Timestamp is not JSON serializable

CSV sample:

SEGMENTID,STREET,DIRECTION,FROM_STREET,TO_STREET,LENGTH, STREET_HEADING, COMMENTS,START_LONGITUDE, START_LATITUDE,END_LONGITUDE, END_LATITUDE, CURRENT_SPEED, LAST_UPDATED
1284,Chicago,WB,Lake Shore Dr,Michigan,0.37,E,,-87.617048,41.896936,-87.624241,41.896835,-1,2011-08-10 00:00:00.0
951,Washington,WB,Kedzie,Schraeder,0.28,W,,-87.7061691246,41.8829315251,-87.7117472865,41.8828184746,-1,2010-07-21 14:51:00.0
750,Elston,SE,Milwaukee,Austin,0.33,N,,-87.7832243493,41.9926646035,-87.7780730735,41.9899051234,-1,2010-07-21 14:51:10.0
1164,Harlem,SB,Ogden,Pershing,0.173022844032,S,Outside City Limits,-87.802921906,41.8237508093,-87.8030252034,41.8212448346,-1,2010-07-21 14:51:15.0
1122,127th,EB,Western,I-57 Expy,0.907892221885,W,Outside City Limits,-87.6800769707,41.6625116506,-87.6625398368,41.6628497334,-1,2010-07-21 14:51:06.0
682,Dr Martin L King Jr,NB,Bishop Ford Expy,95th,0.58,S,,-87.6137714553,41.7134413253,-87.6139718105,41.7218553843,-1,2010-07-21 14:50:44.0
794,Hollywood,WB,Lake Shore Dr,Ridge,0.45,W,part of Peterson,-87.6535171971,41.9855339538,-87.6624036279,41.985180094,-1,2010-07-21 14:50:56.0
964,Ramp To Kennedy,WB,Orleans,Kennedy Expy,0.57,W,Oneway,-87.6370995163,41.8931503343,-87.6481798833,41.8925171987,-1,2010-07-21 14:51:01.0
701,Dr Martin L King Jr,SB,95th,Bishop Ford Expy,0.58,S,,-87.6143380874,41.7218576767,-87.614137688,41.713443618,-1,2010-07-21 14:50:45.0

To Reproduce
Steps to reproduce the behavior:

from preswald import text, plotly, connect, get_df, table
import pandas as pd
import plotly.express as px

text("# Welcome to Preswald!")

# Load the CSV
connect() # load in all sources, which by default is the sample_csv
data = get_df('traffic_csv')

# Show the data
table(data)

Expected behavior
I expect to see a table of the data.

Environment:

  • OS: NixOS (preswald is running in a Docker container built from preswald source repo)
  • Browser: Firefox
  • Version: 134.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions