import pandas as pd
tweets = pd.read_csv("file_name")
# Group the data by hashtag to extract books with the hashtag RoeVWade only
roevwade = tweets.groupby("hashtags").get_group("['RoeVWade']")
# Print the date of the first tweet with only the RoeVWade hashtag
print(roevwade["created_at"][0])
Drops an error:
KeyError: 0
Fixed this using
roevwade["created_at"].iloc[0]
and got what I needed. However, I need another way without using iloc or iat. It must be a single line like here:
print(roevwade["created_at"][0])
but one that doesn't drop an error. I understand this is a series and not a list, but I have no idea how to print what is needed with a single line of code after assigning roevwade var.