1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] using a pandas data frame and it is returning NaN, but when I print the value it is...

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am using pandas for the first time, and in the data frame there is a piece of data that is a percentage as a string but when put into a dataframe and printed it shows up as NaN. So to test it i just used a print statement and it returns the value fine. Thank you!

    def makeSheet():
    data = [schoolName, location, aceptanceRate, tuition, roomAndBoard, debtAtGrad, studentToTeacher, satReq, totalUndergrad]
    dataDictonary = {"School Name": schoolName, "Location": location, "Aceptance Rate": aceptanceRate, "Tuition": tuition, "Room & Board": roomAndBoard, "Estimated Debt at Grad": debtAtGrad, "Student:Teacher": studentToTeacher,
    "SAT Req": satReq, "Total Number of Undergrads": totalUndergrad}
    df = pd.DataFrame(dataDictonary, columns=headers, index=[0])
    print(df)
    print(aceptanceRate)


    the pandas data table returned: pandas data table

    The print statement returned: 31%

    Continue reading...

Compartilhe esta Página