Python 禁用数据帧尺寸打印
熊猫在数据帧后的最后一行打印数据帧尺寸:Python 禁用数据帧尺寸打印,python,pandas,Python,Pandas,熊猫在数据帧后的最后一行打印数据帧尺寸: import pandas as pd print pd.__version__ print pd.DataFrame({'a':[1,2],'b':[3,4]}) 输出: 0.13.0 a b 0 1 3 1 2 4 [2行x 2列]目前,我认为您不能,至少在没有monkeypatchingDataFrame的情况下不能。神奇发生在数据帧中 def __unicode__(self): """ Return a string
import pandas as pd
print pd.__version__
print pd.DataFrame({'a':[1,2],'b':[3,4]})
输出:
0.13.0
a b
0 1 3
1 2 4
[2行x 2列]目前,我认为您不能,至少在没有monkeypatchingDataFrame
的情况下不能。神奇发生在数据帧中
def __unicode__(self):
"""
Return a string representation for a particular DataFrame
Invoked by unicode(df) in py2 only. Yields a Unicode String in both
py2/py3.
"""
buf = StringIO(u(""))
if self._info_repr():
self.info(buf=buf)
return buf.getvalue()
max_rows = get_option("display.max_rows")
max_cols = get_option("display.max_columns")
if get_option("display.expand_frame_repr"):
width, _ = fmt.get_console_size()
else:
width = None
self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
line_width=width, show_dimensions=True)
return buf.getvalue()
您可以看到它通过show_dimensions=True
,而不选中任何选项。您可以自己调用来显示字符串,默认值为show\u dimensions=False
:
>>> df
a b
0 1 3
1 2 4
[2 rows x 2 columns]
>>> print df.to_string()
a b
0 1 3
1 2 4
>>>
ISTM没有理由不使用显示。显示维度
选项。目前,我认为你不能,至少如果没有monkeypatching数据帧
。神奇发生在数据帧中
def __unicode__(self):
"""
Return a string representation for a particular DataFrame
Invoked by unicode(df) in py2 only. Yields a Unicode String in both
py2/py3.
"""
buf = StringIO(u(""))
if self._info_repr():
self.info(buf=buf)
return buf.getvalue()
max_rows = get_option("display.max_rows")
max_cols = get_option("display.max_columns")
if get_option("display.expand_frame_repr"):
width, _ = fmt.get_console_size()
else:
width = None
self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
line_width=width, show_dimensions=True)
return buf.getvalue()
您可以看到它通过show_dimensions=True
,而不选中任何选项。您可以自己调用来显示字符串,默认值为show\u dimensions=False
:
>>> df
a b
0 1 3
1 2 4
[2 rows x 2 columns]
>>> print df.to_string()
a b
0 1 3
1 2 4
>>>
ISTM没有理由不使用显示。显示维度
选项。目前,我认为你不能,至少如果没有monkeypatching数据帧
。神奇发生在数据帧中
def __unicode__(self):
"""
Return a string representation for a particular DataFrame
Invoked by unicode(df) in py2 only. Yields a Unicode String in both
py2/py3.
"""
buf = StringIO(u(""))
if self._info_repr():
self.info(buf=buf)
return buf.getvalue()
max_rows = get_option("display.max_rows")
max_cols = get_option("display.max_columns")
if get_option("display.expand_frame_repr"):
width, _ = fmt.get_console_size()
else:
width = None
self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
line_width=width, show_dimensions=True)
return buf.getvalue()
您可以看到它通过show_dimensions=True
,而不选中任何选项。您可以自己调用来显示字符串,默认值为show\u dimensions=False
:
>>> df
a b
0 1 3
1 2 4
[2 rows x 2 columns]
>>> print df.to_string()
a b
0 1 3
1 2 4
>>>
ISTM没有理由不使用显示。显示维度
选项。目前,我认为你不能,至少如果没有monkeypatching数据帧
。神奇发生在数据帧中
def __unicode__(self):
"""
Return a string representation for a particular DataFrame
Invoked by unicode(df) in py2 only. Yields a Unicode String in both
py2/py3.
"""
buf = StringIO(u(""))
if self._info_repr():
self.info(buf=buf)
return buf.getvalue()
max_rows = get_option("display.max_rows")
max_cols = get_option("display.max_columns")
if get_option("display.expand_frame_repr"):
width, _ = fmt.get_console_size()
else:
width = None
self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
line_width=width, show_dimensions=True)
return buf.getvalue()
您可以看到它通过show_dimensions=True
,而不选中任何选项。您可以自己调用来显示字符串,默认值为show\u dimensions=False
:
>>> df
a b
0 1 3
1 2 4
[2 rows x 2 columns]
>>> print df.to_string()
a b
0 1 3
1 2 4
>>>
ISTM没有理由不使用显示。显示维度选项。想为此做PR吗?@Jeff:我几乎准备好了一个,测试和所有测试,但是repr(df)
和df.to_string()
之间的str/unicode差异让我有点头疼。将讨论@GH.想为此做PR吗?@Jeff:我几乎准备好了一个测试和所有测试,但是repr(df)
和df.to_string()
之间的str/unicode差异让我有点头疼。将讨论@GH.想为此做PR吗?@Jeff:我几乎准备好了一个测试和所有测试,但是repr(df)
和df.to_string()
之间的str/unicode差异让我有点头疼。将讨论@GH.想为此做PR吗?@Jeff:我几乎准备好了一个测试和所有测试,但是repr(df)
和df.to_string()
之间的str/unicode差异让我有点头疼。我们将讨论@GH。