推荐学习书目
› 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 · Feb 27, 2019 · 2911 views
    This topic created in 2822 days ago, the information mentioned may be changed or developed.
    自学小白练习操作 dataframe 遇到的,表述可能不是很清楚。
    能感觉出来是 utf8 这种的问题,但是不知道怎么解决。。
    pd.read_excel 读中文名文件都是报错找不到,改成英文名就可以。
    到了按条件筛选内容的时候,发现似乎我输入的中文和表内的中文不是一个格式,加了 utf8 表头还是没法解决。
    结果如图,请各位帮忙看一下,谢谢!
    https://s2.ax1x.com/2019/02/27/koyekn.png
    yuikns
    yuikns
    Feb 27, 2019 via iPhone
    1
    文件名那个,Windows 文件名貌似不是 utf8

    顺便的,h 的类型会是 str 么?要不要单独条件试试,或者 dtype 指定下类型?
    neoblackcap
    neoblackcap
    Feb 27, 2019
    2
    没记错的话,windows 下面都是 utf16
    flyingpot
    flyingpot
    Feb 27, 2019❤️1
    3
    '美国' -> u'美国' 试一下
    yellowtail
    yellowtail
    OP
    Feb 27, 2019
    4
    @flyingpot 已解决,谢谢。
    yellowtail
    yellowtail
    OP
    Feb 27, 2019
    5
    @yuikns 是 int 加 u 就好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4248 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 05:49 · PVG 13:49 · LAX 21:49 · JFK 00:49
    ♥ Do have faith in what you're doing.