dara-core 1.13.0__py3-none-any.whl → 1.13.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -182,6 +182,7 @@ class DataVariable(AnyDataVariable):
182
182
  store: CacheStore,
183
183
  filters: Optional[Union[FilterQuery, dict]] = None,
184
184
  pagination: Optional[Pagination] = None,
185
+ format_for_display: bool = False,
185
186
  ) -> Optional[DataFrame]:
186
187
  """
187
188
  Get the value of this DataVariable.
@@ -212,6 +213,12 @@ class DataVariable(AnyDataVariable):
212
213
 
213
214
  if entry.data is not None:
214
215
  filtered_data, count = apply_filters(entry.data, coerce_to_filter_query(filters), pagination)
216
+ if format_for_display and filtered_data is not None:
217
+ filtered_data = filtered_data.copy()
218
+ for col in filtered_data.columns:
219
+ if filtered_data[col].dtype == 'object':
220
+ # We need to convert all values to string to avoid issues with displaying data in the Table component, for example when displaying datetime and number objects in the same column
221
+ filtered_data.loc[:, col] = filtered_data[col].apply(str)
215
222
  data = filtered_data
216
223
  # Store count for given filters and schema
217
224
  await asyncio.gather(
@@ -239,6 +239,7 @@ class DerivedDataVariable(AnyDataVariable, DerivedVariable):
239
239
  store: CacheStore,
240
240
  filters: Optional[Union[FilterQuery, dict]] = None,
241
241
  pagination: Optional[Pagination] = None,
242
+ format_for_display: bool = False,
242
243
  ) -> Union[BaseTask, DataFrame, None]:
243
244
  """
244
245
  Get the filtered data from the underlying derived variable stored under the specified cache_key.
@@ -297,6 +298,12 @@ class DerivedDataVariable(AnyDataVariable, DerivedVariable):
297
298
 
298
299
  # Run the filtering
299
300
  data = await cls._filter_data(data, count_cache_key, data_entry, store, filters, pagination)
301
+ if format_for_display and data is not None:
302
+ data = data.copy()
303
+ for col in data.columns:
304
+ if data[col].dtype == 'object':
305
+ # We need to convert all values to string to avoid issues with displaying data in the Table component, for example when displaying datetime and number objects in the same column
306
+ data.loc[:, col] = data[col].apply(str)
300
307
 
301
308
  return data
302
309
 
@@ -332,6 +332,7 @@ def create_router(config: Configuration):
332
332
  store,
333
333
  body.filters,
334
334
  Pagination(offset=offset, limit=limit, orderBy=order_by, index=index),
335
+ format_for_display=True,
335
336
  )
336
337
  if isinstance(data, BaseTask):
337
338
  await task_mgr.run_task(data, body.ws_channel)
@@ -342,6 +343,7 @@ def create_router(config: Configuration):
342
343
  store,
343
344
  body.filters,
344
345
  Pagination(offset=offset, limit=limit, orderBy=order_by, index=index),
346
+ format_for_display=True,
345
347
  )
346
348
 
347
349
  dev_logger.debug(