You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a DataFrame is displayed, the corresponding Result has the data attribute in the format {column -> [values]} (equivalent to df.to_dict(orient="list")). This means that we lose the table index, which can be relevant. Is it possible to use a format that preserves this information?
To keep consistency with pandas' to_dict, any of these options would work:
'dict' (default) : dict like {column -> {index -> value}}
It might take some time since it's a breaking change due to the incompatibility with current format.
To avoid a breaking change, this could be addressed by adding an argument (e.g. in run_code) to control this behavior. The default value can correspond to the current format (making it non-breaking), but then we can explicitly set it to get the desired format.
Following the example above, I could get the expected output with something like sandbox.run_code(code, data_orient="tight") (here I'm following pandas, but could also just be a boolean to switch between the current and full formats).
When a DataFrame is displayed, the corresponding
Result
has thedata
attribute in the format{column -> [values]}
(equivalent todf.to_dict(orient="list")
). This means that we lose the table index, which can be relevant. Is it possible to use a format that preserves this information?To keep consistency with pandas'
to_dict
, any of these options would work:{column -> {index -> value}}
{'index' -> [index], 'columns' -> [columns], 'data' -> [values]}
{'index' -> [index], 'columns' -> [columns], 'data' -> [values], 'index_names' -> [index.names], 'column_names' -> [column.names]}
{index -> {column -> value}}
(Note: 'tight' is the only option that preserves the full information, including the index name)
Example
Expected (one of the options):
The text was updated successfully, but these errors were encountered: