Search code examples
pythonpandascsvdataframetweets

Pandas deletes Header of Dataframe


I am working with a csv that has the sentiment value of a tweet and in the next colum it has the tweet.

data = pd.read_csv("Tweets.csv",encoding="utf-8-sig")

print(data)

print(data.dtypes)

this puts it out like this:

  sentiment,                      tweets
0     neutral                       What @dhepburn said.

I used this code to convert everything to lowercase:

lower = data['tweets'].str.lower()

If I print this, it shows up like this though:

0                             what @dhepburn said.

The headers are gone and I can't work with this. What is wrong with my code?


Solution

  • You simply need to assign back the result:

    data['tweets'] = data['tweets'].str.lower()
    

    Because:

    • data['tweets'].str.lower() : returns a series