Skip to content

Commit

Permalink
feat: pandas_json_dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Feb 21, 2025
1 parent baa98dd commit 8554d30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions tabled/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
expand_columns, # expand columns in a dataframe
auto_decode_bytes, # Decode a byte sequence into a string, trying charset_normalizer gueses if fails.
PandasJSONEncoder, # a json encoder that can handle pandas and numpy objects
pandas_json_dumps, # dump a pandas object to a json string
ensure_columns, # ensure that the columns are in the dataframe
ensure_first_columns, # ensure that the columns are the first columns in the dataframe
ensure_last_columns, # ensure that the columns are the last columns in the dataframe
Expand Down
3 changes: 3 additions & 0 deletions tabled/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,6 @@ def default(self, obj):
return None
# Fallback to the default method.
return super().default(obj)


pandas_json_dumps = partial(json.dumps, cls=PandasJSONEncoder)

0 comments on commit 8554d30

Please sign in to comment.