pandas: rename axis in df
<p>I have a df which looks like this:</p>

<pre><code>                Column 1
Channel          
Apples            1.0
Oranges           2.0
Puppies           3.0
Ducks             4.0
</code></pre>

<p>I would like to rename the axis so it looks like this:</p>

<pre><code>Channel         Column 1          
Apples            1.0
Oranges           2.0
Puppies           3.0
Ducks             4.0
</code></pre>

<p>I tried these but got the same error msg:</p>

<pre><code>merged_df.rename_axis("Channel")
merged_df.rename_axis("Channel", axis='columns')

TypeError: 'str' object is not callable
</code></pre>

<p>This is kind of a hack to get you what you eventually wanted it to look like.</p>

<pre><code>df = pd.read_csv(data, sep='\s{2,}', index_col='Channel', engine='python')
df
</code></pre>

<p><a href="http://i.stack.imgur.com/CLcCU.png" rel="nofollow"><img src="http://i.stack.imgur.com/CLcCU.png" alt="Image"></a></p>

<pre><code>df_excel_format = df.rename_axis('Channel', axis=1)
del(df_excel_format.index.name)
df_excel_format
</code></pre>

<p><a href="http://i.stack.imgur.com/Fpif7.png" rel="nofollow"><img src="http://i.stack.imgur.com/Fpif7.png" alt="Image"></a></p>

python pandas dataframe