推荐学习书目
› 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
n2l
V2EX  ›  Python

pandas 链式赋值总得用 copy

  •  
  •   n2l · Jan 15, 2022 · 2638 views
    This topic created in 1722 days ago, the information mentioned may be changed or developed.

    总会遇到链式赋值的提醒,无奈只能反复用 copy ,请问有没有类似 c 指针之类的操作,我只想修改源数据,要这么多 copy 后的玩意儿干啥

    1 replies  •  2022-01-15 15:41:53 +08:00
    imn1
        1
    imn1  
       Jan 15, 2022   ❤️ 1
    如果只是修改源数据,可以多用 inplace=True

    整列赋值的话,其实不多触发提醒,一般都是跨列赋值,或者 apply 才出现
    但这个东西确实是烦,没辙,谁叫 python 大部分变量都是引用呢

    如果只是部分行赋值,单值用 mask ,多值用 update ,index 匹配上就行了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   942 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:47 · PVG 07:47 · LAX 16:47 · JFK 19:47
    ♥ Do have faith in what you're doing.