V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yellowtail
V2EX  ›  Python

请问怎么解决用 juypternotebook 跑 python2, pandas 条件检索中文失败的问题。。

  •  
  •   yellowtail · 2019-02-27 04:41:30 +08:00 · 1776 次点击
    这是一个创建于 1886 天前的主题,其中的信息可能已经有所发展或是发生改变。
    自学小白练习操作 dataframe 遇到的,表述可能不是很清楚。
    能感觉出来是 utf8 这种的问题,但是不知道怎么解决。。
    pd.read_excel 读中文名文件都是报错找不到,改成英文名就可以。
    到了按条件筛选内容的时候,发现似乎我输入的中文和表内的中文不是一个格式,加了 utf8 表头还是没法解决。
    结果如图,请各位帮忙看一下,谢谢!
    https://s2.ax1x.com/2019/02/27/koyekn.png
    yuikns
        1
    yuikns  
       2019-02-27 06:03:32 +08:00 via iPhone
    文件名那个,Windows 文件名貌似不是 utf8

    顺便的,h 的类型会是 str 么?要不要单独条件试试,或者 dtype 指定下类型?
    neoblackcap
        2
    neoblackcap  
       2019-02-27 15:07:15 +08:00
    没记错的话,windows 下面都是 utf16
    flyingpot
        3
    flyingpot  
       2019-02-27 15:10:12 +08:00   ❤️ 1
    '美国' -> u'美国' 试一下
    yellowtail
        4
    yellowtail  
    OP
       2019-02-27 16:02:14 +08:00
    @flyingpot 已解决,谢谢。
    yellowtail
        5
    yellowtail  
    OP
       2019-02-27 22:34:49 +08:00
    @yuikns 是 int 加 u 就好了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1233 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:48 · PVG 07:48 · LAX 16:48 · JFK 19:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.