错误如下

UnicodeDecodeError Traceback (most recent call last)

in ()

1 df = pd.read_table("city.csv",

----> 2 encoding="utf-8",)

C:\123\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)

644 skip_blank_lines=skip_blank_lines)

645

--> 646 return _read(filepath_or_buffer, kwds)

647

648 parser_f.__name__ = name

C:\123\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)

387

388 # Create the parser.

--> 389 parser = TextFileReader(filepath_or_buffer, **kwds)

390

391 if (nrows is not None) and (chunksize is not None):

C:\123\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)

728 self.options['has_index_names'] = kwds['has_index_names']

729

--> 730 self._make_engine(self.engine)

731

732 def close(self):

C:\123\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)

921 def _make_engine(self, engine='c'):

922 if engine == 'c':

--> 923 self._engine = CParserWrapper(self.f, **self.options)

924 else:

925 if engine == 'python':

C:\123\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds)

1388 kwds['allow_leading_cols'] = self.index_col is not False

1389

-> 1390 self._reader = _parser.TextReader(src, **kwds)

1391

1392 # XXX

pandas\parser.pyx in pandas.parser.TextReader.__cinit__ (pandas\parser.c:6086)()

pandas\parser.pyx in pandas.parser.TextReader._get_header (pandas\parser.c:9266)()

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 0: invalid continuation byte

代码如下

import pandas as pd

df = pd.read_table("city.csv",

encoding="utf8",)

python pandas csv getitem_Python调用pandas 读csv档时出现了错误相关推荐

  1. python 读取csv带表头_python读csv文件时指定行为表头或无表头的方法

    pd.read_csv()方法中header参数,默认为0,标签为0(即第1行)的行为表头.若设置为-1,则无表头.示例如下: (1)不设置header参数(默认)时: df1 = pd.read_c ...

  2. java csv 复杂表头_java读csv 和excel

    以前各种包都用过,操作了无数csv 和excel. 从来没有记录过.下面写了个简单例子,不过对于excel还是建议使用poi来操作.我没有封装,只是事例而已. import java.io.File; ...

  3. python把csv做成柱状图_python读csv格式文档并用matplotlib绘制图表

    import csv from matplotlib import pyplot as plt from datetime import datetime fileName = 'sitka_weat ...

  4. python转exe可执行程序在其他系统上运行时出现的错误

    说明:python转exe在win10上执行,无法运行在win7系统上 一.win7旗舰版x64 运行错误提示 解决办法 下载api-ms-win-crt-runtime-l1-1-0.dll复制到系 ...

  5. python microbit typeerror,在MicroPython中使用microbit模块时出现索引错误

    我是个业余爱好者,所以我还在学习.我放弃了我的旧代码,因为我很早就被卡住了.我想出了一个更"基于整数"的脚本,而不是使用预先设置的图像.我认为使用简单的整数可以更容易地使用控制流, ...

  6. python怎么写csv文件_python怎么写csv文件

    最常用的一种方法,利用pandas包.import pandas as pd #任意的多组列表 a = [1,2,3] b = [4,5,6] #字典中的key值即为csv中列名 dataframe  ...

  7. python导入文件列行_python读写csv文件并增加行列的实例代码

    python读写csv文件并增加行列,具体代码如下所示: # -*- coding: utf-8 -*- """ Created on Thu Aug 17 11:28: ...

  8. pandas处理mysql 展现wpf_Python:用Pandas读CSV文件写到MySQL

    汇总一下,自己最近在使用Python读写CSV存数据库中遇到的各种问题. 上代码: reload(sys) sys.setdefaultencoding('utf-8') host = '127.0. ...

  9. python pandas csv 写文件_Pandas读写CSV文件的方法介绍(附代码)

    本篇文章给大家带来的内容是关于Pandas读写CSV文件的方法介绍(附代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 读csv:使用pandas读取import pandas ...

最新文章

  1. 7 = 350 000 000 ?!
  2. sqoop操作之HIVE导出到ORACLE
  3. 【剑指offer-Java版】07用两个栈实现队列
  4. P1145 约瑟夫 W(模拟)
  5. vue面试题,知识点汇总(有答案)
  6. python生成二维坐标点_Python numpy:根据坐标创建二维数组
  7. Proxmox VE中出现TASK ERROR: command ‘apt-get update‘ failed: exit code 100的解决方法
  8. Java SE 9:使用Eclipse和IntelliJ IDEA IDE开发和测试HelloWorld模块(第4部分)
  9. Android 性能指标检测工具
  10. MATLAB中一些特殊的函数
  11. 语言abline画不出线_北师大版八下数学 2.1不等关系 知识点精讲
  12. 各种电子元器件介绍与电路基础作用
  13. 安川机器人焊枪切换设定方法_安川机器人工具、用户、安全模式设定方法
  14. git使用kdiff3合并乱码问题
  15. 2022-基于树木形态和有限状态机的森林火灾蔓延实时三维可视化
  16. 电子印章怎么验证真假?
  17. (Tiled官方文档翻译)第四节:对象的编辑和使用
  18. 写代码也要讲规矩——SLA
  19. 多所985大学退出国际排名,会是大势所趋吗?
  20. 控制台报错:Unknown database ‘xxxxx‘

热门文章

  1. 冲上热搜!8次手术没有倒下,截肢少年考出684分!清华发声
  2. 海底光缆——你不知道的秘密!
  3. 这40张图送给单身程序员,情人节请一笑而过!
  4. 解析得了数学,写得了诗书,这是个有趣的灵魂
  5. Audio-based snore detection using deep neural networks解读
  6. 【使用注意】Boolean是final类型,值初始化后不能被更改
  7. 【转载】RocketMQ优秀文章
  8. web通讯录之登录注册界面
  9. 数据结构实验之栈七:出栈序列判定
  10. osg学习笔记(一)