Suppress descriptive output when printing pandas dataframe

numpy, output-formatting, pandas, python

Solution

You can tweak the `__unicode__` method for a Series:

In [11]: s = pd.Series([1, 2])

In [12]: s
Out[12]:
0    1
1    2
dtype: int64

In [13]: pd.Series.__unicode__ = pd.Series.to_string

In [14]: s  # same with print
Out[14]:
0    1
1    2

To append to a csv use append mode (see this or this question).

Problem

Say I have dataframe, `c`: ``` a=np.random.random((6,2)) c=pd.DataFrame(a) c.columns=['A','B'] ``` printing row 0 values: ``` print c.loc[(0),:] ``` results in: ``` A 0.220170 B 0.261467 Name: 0, dtype: float64 ``` I would like to suppress the `Name: 0, dtype: float64` line so that I just get: ``` A 0.220170 B 0.261467 ``` Does anyone know how? (n.b. I am appending this to a text file)

Original source

Related problems