Switch order of df logic. (#396)

This commit is contained in:
Alek Petuskey 2023-01-30 10:28:38 -08:00 committed by GitHub
parent a5bd23d792
commit ca637801a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,11 +69,6 @@ class DataTable(Gridjs):
)
def _render(self) -> Tag:
# If given a pandas df break up the data and columns
if utils.is_dataframe(type(self.data)):
self.columns = Var.create(list(self.data.columns.values.tolist())) # type: ignore
self.data = Var.create(list(self.data.values.tolist())) # type: ignore
# If given a var dataframe, get the data and columns
if isinstance(self.data, Var):
self.columns = BaseVar(
@ -87,5 +82,10 @@ class DataTable(Gridjs):
state=self.data.state,
)
# If given a pandas df break up the data and columns
if utils.is_dataframe(type(self.data)):
self.columns = Var.create(list(self.data.columns.values.tolist())) # type: ignore
self.data = Var.create(list(self.data.values.tolist())) # type: ignore
# Render the table.
return super()._render()