Remove space and newlines in pandas columns using idiomatic Python?
<p>I am using the below method to replace all the spaces and new line characters in the pandas dataframe column headers.</p>

<p>My question is:</p>

<p>Is a more efficient way to loop using the list comprehensions in the below code ?</p>

<pre><code>def headerfiller(df):
    for i in [" ","\n"]:
        df.columns = [c.replace(i,"_") for c in df.columns]
</code></pre>