harshmangalamv
harshmangalamv

Reputation: 43

Adding a column with no header to a dataframe

How can I add an empty column to my dataframe without introducing a header to it?

I am using pandas to work on a dataframe where I need to add an empty column without any header. I know that by using

df["New_Column_Name"] = "" 

(where df is my dataframe) would add an empty column to the df. But, in my case I don't want that "New_Column_Name" there. Thanks.

Upvotes: 0

Views: 766

Answers (1)

ADL
ADL

Reputation: 154

data = {'Name': ['Rob', 'Bob', 'Tob'],
        'Age': [20, 21, 19]}
df = pd.DataFrame(data)
df[''] = ''
print(df.columns)

output:

Index(['Name', 'Age', ''], dtype='object')

Upvotes: 1

Related Questions