[Python] Pandas iloc function output not returning iterable string

Discussão em 'Python' iniciado por Stack, Junho 29, 2025.

  1. Stack

    Stack Membro Participativo

    i am retrieving data from an html table using pandas and i have used iloc inorder to get a specific value and i want to be able to split that string or replace some letters in that string, the output i get is a string as i checked with the type() function, i also tried the str() function with no luck, whenever i try to split the output goes from a321 [NXXXXXXX] to just 321, even when i try to split at a whitespace. i suspect it might be because the iloc output is not like a regular python string and does not behave like one but i am not sure, i am very new to pandas. this is my code -

    dfs = pd.read_html(content)
    df = dfs[0]
    date = "29 Ju 2025"
    index = df.isin([date]).any(axis=1).idxmax()
    flight_details = df.iloc[index,5]
    details = flight_details.split(' ')
    print(details)

    Continue reading...

Compartilhe esta Página