I have a data frame that contains a column with long texts.
To demonstrate how it looks (note the ellipses "..." where text should continue):
id text group
123 My name is Benji and I ... 2
The above text is actually longer than that phrase. For example it could be:
My name is Benji and I am living in Kansas.
The actual text is much longer than this.
When I try to subset the text column only, it only shows the partial text with the dots "...".
I need to make sure full text is shown for text sumarization later. But I'm not sure how to show the full text when selecting the text column.
My df['text']
output looks something like this:
1 My name is Benji and I ...
2 He went to the creek and ...
How do I show the full text and without the index number?
You can convert to a list an join with newlines ("\n"
):
import pandas as pd
text = """The bullet pierced the window shattering it before missing Danny's head by mere millimeters.
Being unacquainted with the chief raccoon was harming his prospects for promotion.
There were white out conditions in the town; subsequently, the roads were impassable.
The hawk didn’t understand why the ground squirrels didn’t want to be his friend.
Nobody loves a pig wearing lipstick."""
df = pd.DataFrame({"id": list(range(5)), "text": text.splitlines()})
Original output:
print(df["text"])
Yields:
0 The bullet pierced the window shattering it be...
1 Being unacquainted with the chief raccoon was ...
2 There were white out conditions in the town; s...
3 The hawk didn’t understand why the ground squi...
4 Nobody loves a pig wearing lipstick.
Desired output:
print("\n".join(df["text"].to_list()))
Yields:
The bullet pierced the window shattering it before missing Danny's head by mere millimeters.
Being unacquainted with the chief raccoon was harming his prospects for promotion.
There were white out conditions in the town; subsequently, the roads were impassable.
The hawk didn’t understand why the ground squirrels didn’t want to be his friend.
Nobody loves a pig wearing lipstick.