Search code examples
pythonpandasseries

Python pandas series - how can I print only the value without the other information


I have a Python series that gives me the following:

df_1974.loc[[df_1974["Close*"].idxmin()]]['date_final']

type(df_1974.loc[[df_1974["Close*"].idxmin()]]['date_final'])

df_1974.loc[[df_1974["Close*"].idxmin()]]['date_final']
Out[8]: 
12099   1974-10-03
Name: date_final, dtype: datetime64[ns]

type(df_1974.loc[[df_1974["Close*"].idxmin()]]['date_final'])
Out[9]: pandas.core.series.Series

How can I print only the value 1974-10-03 without the other information?


Solution

  • You can convert this to_numpy() or to_list() or values and print the 0th element. e.g.,

    >>> df_1974.loc[[df_1974["Close*"].idxmin()]]['date_final'].astype("str").to_list()[0]
    >>> '1974-10-03'