I have a dataframe say dfdata
in a jupyter server notebook running on a remote machine).
I want to access the dataframe in the remote machine memory to my local machine, say to paste the dfdata
to Excel.
Normally (when the notebook server is running locally), I do dfdata.to_clipboard()
to copy the dataframe to clipboard and now able to paste it to Excel.
However, since the dfdata
is now on the remote machine, the dfdata.to_clipboard()
does not have the copy of the dataframe in clipboard.
How to make this work, i.e. copy paste dataframe from remote machine to locally running Excel, Textfile, etc.? Any alternative methods, if to_clipboard()
by design will not work across remote server due to any security restrictions / limitations.
I wrote a Jupyter nbextension to do this (installation instructions in the README).
It overwrites Panda's pandas.io.clipboard.copy
& pandas.io.clipboard.clipboard_set
(which is an embedded copy of pyperclip) to send messages to the Jupyter frontend via the Comm mechanism. I had to add a simple bootstrap-based UI that pops up when the client-side JS receives a message, as browsers won't let you push data onto the system clipboard without explicit user interaction (security!).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With