-
|
Following this discussion (#2026), I can view a pandas Dataframe in visidata using I wonder whether visidata can also be used to edit the dataframe. That is, I want something like https://www.visidata.org/docs/loading/ suggests that this is not possible for R: "Please note, that this tool opens the data frame in readonly mode." However, 10 Ways to use Visidata (https://www.visidata.org/blog/2020/ten/) gives the example for the shell. Does anybody know if there is something similar for Pandas dataframes in python REPL? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
One thing to keep in mind for the notebook environment, the cells are very ephemeral and many workflows involve re-executing a cell. So you re-execute a cell where you have visidata state, what happens to that visidata state? I'm not familiar with this integration. If you are just shelling out to visidata and still have a terminal running visidata terminal running somewhere, then you re-run the same cell and you get a new terminal window, you should be fine. If the terminal runs in place, you are left with a tricky situation. One thing you could do is keep track of which dataframe was sent in, then you could display a dialogue saying "you already made edits to this dataframe, do you want to start from there?" Tracking to see if the same dataframe is sent as an argument to a function is a bit tricky. Curious to see how visidata approaches this. |
Beta Was this translation helpful? Give feedback.
-
|
I do not know if I understand your comment, but maybe I am to naive: I just want visidata act as some python function in the sense that it simply returns a I like the astonishing simplicity of What a great piece of software. |
Beta Was this translation helpful? Give feedback.
-
|
Because the visidata Then in your REPL, when you want to view the dataframe and keep the edited result, do: However, I don't use Pandas or IPython, so I can't be sure this works in depth. Check the results carefully to make sure it's keeping all the changes to your edited dataframe! |
Beta Was this translation helpful? Give feedback.
-
|
Right now, I was struggling with the implementation of my plan when I saw your answer. Thanks a lot! This indeed is much better than the solution I suggested. |
Beta Was this translation helpful? Give feedback.
Because the visidata
PandasSheetobject uses a dataframe internally, asself.df, I think there is a simple way to do what you want. In your REPL setup, defineedit_pandas, a slightly modified version of view_pandas().Then in your REPL, when you want to view the dataframe and keep the edited result, do:
However, I don't use Pandas or IPython, so I can't be sure this works in depth. Check the results carefully to make sure it's k…