Skip to content
Advertisement

How can I get unique values from csv?

I have a small question. How can I print all the texts belonging to that author by selecting the author from the csv that I read with the pandas below, can you help with the python code? (ex. I want to display all texts where eap is author.)

Thank you!

id      text                                                author
id26305 This process, however, afforded me no means of...   EAP
id17569 It never once occurred to me that the fumbling...   HPL
id11008 In his left hand was a gold snuff box, from wh...   EAP
id27763 How lovely is spring As we looked from Windsor...   MWS
id12958 Finding nothing else, not even gold, the Super...   HPL

Advertisement

Answer

Hey try out using loc() to get back the series.

df.loc[df['author'] == 'EAB', 'text']

Also check out this Similar question

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement