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

UI.table from_pandas method #1983

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

zilch42
Copy link

@zilch42 zilch42 commented Nov 9, 2023

Adds from_pandas method to ui.table based on the similar method in ui.aggrid.

Addresses #1972, including conversion of the non-serializable datatypes identified in #1698

I think I have updated all of the documentation and tests but let me know if I have missed anything.

Copy link
Contributor

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this wonderful pull request, @zilch42!
Let's merge it right away 🚀

@falkoschindler falkoschindler added the enhancement New feature or request label Nov 9, 2023
@falkoschindler falkoschindler added this to the 1.4.3 milestone Nov 9, 2023
@falkoschindler falkoschindler merged commit efe2755 into zauberzeug:main Nov 9, 2023
1 check passed
@zilch42 zilch42 deleted the ui.table-from-_pandas branch November 10, 2023 00:28
@rohitsathish
Copy link

@falkoschindler, as far as I can see, this problem still persists in 1.4.12.
I get the following error when using ui.table.from_pandas():

Type is not JSON serializable: Timestamp
TypeError: Object of type Timestamp is not JSON serializable

@falkoschindler
Copy link
Contributor

@rohitsathish Can you share a minimal reproducible code example? The following code seems to be working:

df = pd.DataFrame({'Name': ['John'], 'DOB': ['1/1/2000']})
df['DOB'] = pd.to_datetime(df['DOB'])
ui.table.from_pandas(df)

@rohitsathish
Copy link

rohitsathish commented Mar 15, 2024

@falkoschindler, looks like the time component is causing the error.

df = pd.DataFrame({'Name': ['John'], 'DOB': ['2021-06-25 03:00:00+00:00']})
df['DOB'] = pd.to_datetime(df['DOB'])
ui.table.from_pandas(df)

@falkoschindler
Copy link
Contributor

falkoschindler commented Mar 15, 2024

@rohitsathish Looks like the timezone is causing the error. 🤦‍♂️
This works:

df = pd.DataFrame({'Name': ['John'], 'DOB': ['2021-06-25 03:00:00']})
df['DOB'] = pd.to_datetime(df['DOB'])
ui.table.from_pandas(df)

I'll create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants