python-3.x - 在 Google Colaboratory 中显示 pandas 数据框时出错
问题描述
我在 Google Colab python(3.6) 笔记本中构建了一个数据分析管道。每当我尝试内联显示 pandas(0.23.4) 数据框时,都会出现以下错误:
TypeError: init () got an unexpected keyword argument 'max_rows'
似乎唯一能解决问题的是创建一个新的 colab 笔记本。(文件>新笔记本)。但即便如此,在使用一段时间后最终还是会遇到同样的问题。
此外,重要的是要注意数据框可以正常工作以进行计算和访问值。显示它似乎是一个问题。
df.head()
结果是:
TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj)
336 method = get_real_method(obj, self.print_method)
337 if method is not None:
--> 338 return method()
339 return None
340 else:
2 frames
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in _repr_html_(self)
694 See Also
695 --------
--> 696 to_html : Convert DataFrame to HTML.
697
698 Examples
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in to_html(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, bold_rows, classes, escape, max_rows, max_cols, show_dimensions, notebook, decimal, border, table_id)
2035 Dictionary mapping columns containing datetime types to stata
2036 internal format to use when writing the dates. Options are 'tc',
-> 2037 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer
2038 or a name. Datetime columns that do not have a conversion type
2039 specified will be converted to 'tc'. Raises NotImplementedError if
/usr/local/lib/python3.6/dist-packages/pandas/io/formats/format.py in to_html(self, classes, notebook, border)
751 need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))
752
--> 753 def space_format(x, y):
754 if (y not in self.formatters and
755 need_leadsp[x] and not restrict_formatting):
TypeError: __init__() got an unexpected keyword argument 'max_rows'
预期结果是将数据框显示在 html 表中。
解决方案
推荐阅读
- reactjs - ReactNative - 字体颜色不适用于三星设备
- python - 试图在我的 PyQt5 Gui 上绘制图表,但无法显示
- java - 当我第一次运行我的应用程序时,你不认为 runTimer() 方法会无限运行,因此永远不会调用 onStart() 方法吗?
- python - 在excel电子表格中搜索URL并使用python打印相应的行
- javascript - React x TypeScript 中的 dxf 查看器
- pyspark - 像 SAS 那样逐行保留 Pyspark 中的值
- android - Android Studio gradle 用户主页无法在 Windows 环境中运行
- python - 如何从 EventBridge 转发到 Lambda 的事件中获取实例 ID
- google-apps-script - 如何在 Google 表格中标记绘图以使用 Google 脚本进行参考
- python - 是否可以使用应用程序功能将文件直接下载到文件/blob sotrage?