大 pandas read_clipboard在大 pandas 0.12中损坏了吗? [英] Pandas read_clipboard broken in pandas 0.12?

查看:127
本文介绍了大 pandas read_clipboard在大 pandas 0.12中损坏了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我将熊猫从0.11版本更新到0.12以来,read_clipboard似乎不再起作用:

Since I updated pandas from version 0.11 to 0.12, read_clipboard doesn't seem to work anymore:

import pandas as pd

df = pd.read_clipboard()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-6dead334eb54> in <module>()
----> 1 df = pd.read_clipboard()

C:\Python33\lib\site-packages\pandas\io\clipboard.py in read_clipboard(**kwargs)
     16     from pandas.io.parsers import read_table
     17     text = clipboard_get()
---> 18     return read_table(StringIO(text), **kwargs)
     19 
     20 

TypeError: initial_value must be str or None, not bytes

我所做的是:

  • 在Excel 2010中打开一个csv文件

  • Open a csv file in Excel 2010

复制一系列单元格,包括标题

Copy a range of cells, including headers

按照上述代码块中的说明在iPython Qt控制台中执行read_clipboard

Perform read_clipboard in iPython Qt console as described in above code block

降级到0.11后,此过程再次正常运行.我正在为python 3.3 Win7 32位使用pandas.

After downgrading to 0.11, this procedure worked fine again. I'm using pandas for python 3.3 Win7 32 bit.

这是熊猫中的虫子吗?有关如何解决此问题的任何建议?

Is this a bug in pandas? Any suggestions on how to resolve this issue?

推荐答案

这是呈现给py3的字符串中的错误;我会在master中修复它,但是您可以进行本地编辑.

Its a bug in the string presented to py3; I'll fix it in master, but you can do this local edit.

C:\python33\Lib\site-packages\pandas\io\clipboard.py

text = clipboard_get()

添加text = text.decode('UTF-8')

显然,剪贴板例程在py3中为您提供了字节(而不是字符串)

apparently the clipboard routine gives you back bytes (and not a string) in py3

这篇关于大 pandas read_clipboard在大 pandas 0.12中损坏了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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