When you do
df[[col]]
in Jupyter, pandas hands off to its HTML‐representation hook (DataFrame.repr_html). That generates a little chunk of HTML + CSS in which the column headers (the <th>s) are by default rendered in italics:
<style type="text/css">
.dataframe th {
text-align: right;
font-style: italic; ←── this is why your headers look “fancy” and slanted
}
…
</style>
<table class="dataframe"> …
By contrast, when you do
df[col]
you get back a Series, and Jupyter shows you the plain‐text repr (no HTML/CSS), so everything looks “normal.”
—––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
getting “plain” text out of it
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
-
Print or to_string()
If you just want to see it in your notebook without italics, do
print(df)
or
df.to_string()
That uses the text-repr everywhere.
-
to_markdown()
If you like GitHub-flavor tables:
from IPython.display import Markdown, display
display(Markdown(df.to_markdown()))
-
Extract the column as a Series
If you actually need the raw Python strings:
series = df[col] # this is a Series of plain str
lst = df[col].tolist() # a list of plain str
arr = df[col].values # a NumPy array of plain str
-
Turn off the default italic headers
If you still want the HTML table but no italics, you can override the CSS:
df.style.set_table_styles([
{'selector': 'th', 'props': [('font-style','normal')]}
])
or inject your own CSS in the notebook:
from IPython.display import HTML
HTML("""
.dataframe th { font-style: normal !important; }
""")
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
In short, you’re seeing italics because of pandas’ default HTML/CSS for DataFrames in Jupyter. If you want raw text, either extract the Series with df[col], or use one of the “print-style” methods (print, .to_string(), .to_markdown(), etc.) instead of the HTML repr.