pandas筛选某列出现编码错误的解决方法
作者:心很大很大 时间:2021-10-18 02:48:05
如下所示:
df = df[df['cityname']==u'北京市']
记得,如果用的python2,一定要导入
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
或者在中文前面加入u'表示unicode编码的,因为pandas对象中中文字符为unicode类型的。
来源:https://blog.csdn.net/tongjinrui/article/details/80498862
标签:pandas,筛选,编码
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SqlServer表死锁的解决方法分享
2011-09-30 11:16:16
价值3亿美元的按钮[译]
2009-03-18 19:39:00
使用Python解决常见格式图像读取nii,dicom,mhd
2021-11-14 23:36:59
django和vue互传图片并进行处理和展示
2021-04-24 20:39:16
Python Trie树实现字典排序
2023-08-23 02:06:10
![](https://img.aspxhome.com/file/2023/3/61223_0s.jpg)
php替换字符串中间字符为省略号的方法
2023-09-30 20:16:04
详解如何用SQLyog来分析MySQL数据库
2008-10-13 12:35:00
![](https://img.aspxhome.com/file/UploadPic/200810/13/SQLyog-mysql_15s.jpg)
python基于opencv实现人脸识别
2021-10-15 12:49:16
![](https://img.aspxhome.com/file/2023/8/68468_0s.jpg)
sublime text配置node.js调试(图文教程)
2023-07-04 14:07:57
![](https://img.aspxhome.com/file/2023/8/55898_0s.png)
django manage.py扩展自定义命令方法
2023-11-03 20:55:42
![](https://img.aspxhome.com/file/2023/5/64225_0s.jpg)
CSS Frameworks的概念
2008-01-23 18:41:00
PHP设计模式之解释器模式浅析
2023-05-29 02:28:16
Python中利用ItsDangerous快捷实现数据加密
2022-06-09 23:24:41
![](https://img.aspxhome.com/file/2023/3/67283_0s.jpg)
将pytorch的网络等转移到cuda
2023-08-10 08:33:46
php中关于普通表单多文件上传的处理方法
2023-11-14 20:21:21
使用go求幂的几种方法小结
2023-09-23 05:07:45
![](https://img.aspxhome.com/file/2023/6/99066_0s.jpg)
10个很实用的js小脚本代码
2007-10-17 21:08:00
BootStrap创建响应式导航条实例代码
2023-08-09 02:09:55
![](https://img.aspxhome.com/file/2023/4/56054_0s.gif)
关于Pyinstaller闪退的补救措施
2021-04-22 06:27:08
![](https://img.aspxhome.com/file/2023/5/80635_0s.jpg)
python把ipynb文件转换成pdf文件过程详解
2022-07-27 23:50:24
![](https://img.aspxhome.com/file/2023/1/84971_0s.png)