[Python] pandas sort_values leaves scientific notation values at end of series

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to sort a pandas dataframe by one of the columns in descending order, but the column contains some very small values in scientific notation which get placed at the end of the series. How can I make these values be recognised as scientific notation?

    data = pd.read_csv('kepsr noneq wall/mesh 13 395 kepsrnoneq main el cp.txt', delimiter="\t", header=None, names=["xc", "cp"])
    data.drop(data.head(3).index,inplace=True)
    data.drop(data.tail(1).index,inplace=True)
    pd.to_numeric(data.xc)
    data = data.sort_values(by=['xc'], ascending=True).reset_index(drop=True)
    xc = data.xc
    cp = data.cp

    Continue reading...

Compartilhe esta Página