str 说白了是调用 __str__ 方法,让数据源自己决定输出什么,和 print 类似。
而 pandas 在 print 时,为了美观,会在打印大量数据的时候省略中间的部分
你可以看到输出最后面还有一段 pandas 提供的 数据类型提示。
因为这个方法通常是用于生成”给人看“的文字,而不是程序用的数据
引用
display.max_colwidth: [default: 50] [currently: 50]
: int
The maximum width in characters of a column in the repr of
a pandas data structure. When the column overflows, a "..."
placeholder is embedded in the output.
你现在可以通过 df.trip_start_time.dtype 看一下数据内部的具体类型,来决定使用什么方法进行序列化
如果你执意要使用 str 进行序列化,也可以通过提前运行以下代码来开启完整输出
复制代码- pd.set_option('display.max_columns', None)
- pd.set_option('display.max_rows', None)
- pd.set_option('max_colwidth',999)
|