瀏覽代碼

Switch order of df logic. (#396)

Alek Petuskey 2 年之前
父節點
當前提交
ca637801a6
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      pynecone/components/datadisplay/datatable.py

+ 5 - 5
pynecone/components/datadisplay/datatable.py

@@ -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()