从远程到本地计算机的jupyter服务器dfdata.to_clipboard.如何? [英] jupyter server dfdata.to_clipboard from remote to local machine. how?

查看:102
本文介绍了从远程到本地计算机的jupyter服务器dfdata.to_clipboard.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程计算机上运行的 jupyter服务器笔记本中有一个数据帧,例如dfdata..

I have a dataframe say dfdata in a jupyter server notebook running on a remote machine).

我想将远程计算机内存中的数据帧访问本地计算机,例如将dfdata粘贴到Excel.

I want to access the dataframe in the remote machine memory to my local machine, say to paste the dfdata to Excel.

通常(当笔记本服务器在本地运行时),我执行dfdata.to_clipboard()将数据框复制到剪贴板,现在能够将其粘贴到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.

但是,由于dfdata现在位于远程计算机上,因此dfdata.to_clipboard()在剪贴板中没有数据框的副本.

However, since the dfdata is now on the remote machine, the dfdata.to_clipboard() does not have the copy of the dataframe in clipboard.

如何实现此目的,即将粘贴数据帧从远程计算机复制到本地运行的Excel,文本文件等?由于设计上的to_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.

推荐答案

我写了Jupyter nbextension做(自述文件中的安装说明).

I wrote a Jupyter nbextension to do this (installation instructions in the README).

它会覆盖熊猫的pandas.io.clipboard.copy& pandas.io.clipboard.clipboard_set(这是 pyperclip 的嵌入式副本),可通过<一种href ="http://jupyter-notebook.readthedocs.io/en/stable/comms.html#opening-a-comm-from-the-kernel" rel ="nofollow noreferrer"> Comm 机制.我必须添加一个简单的基于引导程序的UI,当客户端JS收到消息时,该UI会弹出,因为浏览器

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!).

这篇关于从远程到本地计算机的jupyter服务器dfdata.to_clipboard.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆