Python每日一记38>>>pandas相关小问题
2019-04-15 22:39
211 查看
最近在做新会员,老会员,离返会员的建模分析,在使用pandas中遇到很多问题
1、关于pandas中update的报错cannot reindex from a duplicate axis
这个问题显示你的dataframe的行索引有重复,重新索引编码即可。
我的问题是因为我将两个数据框concat后,索引有重复的。
网上有很多解释,但是只有重新编码行索引才解决了我的问题
df.index=[ ],即可
2、df.loc[df[‘年龄’]==[12,34,56,13,45],:]
这种筛选的方法是错误的,应该df.loc[df[‘年龄’].isin[12,34,56,13,45],:]
取反则应该df.loc[~df[‘年龄’].isin[12,34,56,13,45],:]
具体参考https://blog.csdn.net/sigtem/article/details/81735242
3、交集,并集、差集
注意集合才有这些方法
再需要在pandas中进行后续筛选时,转化为list即可
相关文章推荐
- Python每日一记39>>>pandas创建数据透视表&多维数据问题
- python中写入csv,excel显示、pandas读取csv文件的编码问题
- SWIG Python-C封装 char*相关问题(2)
- 【每日面试题】链表相关问题1
- Python 基础 —— float("inf") 无穷的相关问题
- 使用Python的pandas库读Excel表格.xlsx格式无法读取问题
- Python2.x中str与unicode相关问题的解决方法
- python中文字符乱码(GB2312,GBK,GB18030相关的问题)
- SWIG Python-C封装 char*相关问题(1)
- python使用问题 "The pandas.io.data module is moved to a separate package "
- 【每日一记3.16】python学习记录3----字典,列表,元组
- SWIG Python-C封装 char*相关问题(3)
- Python 爬虫相关问题
- python基础知识整理5——类方法、静态方法和继承相关问题
- 解决Python Pandas 读取Oracle数据库中文乱码问题
- python --中文相关问题
- NS3编译遇到的Python相关的问题解决办法
- python 中super类的相关问题(转载)
- python中多重继承相关问题
- python 相关问题集锦