1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to be sure that my data types are float64 in my equations?

Discussion in 'Programming/Internet' started by Mypel, Sep 12, 2018.

  1. Mypel

    Mypel Guest

    I have a DataFrame with index (Dates) and two columns (A and B). The DataFrame type, is float64 at these columns.

    I am using for loop, to make some calculations. and i want to add the results x1 and x2 to a new columns, Alpha and Beta, Respectively.

    I tried to use the following line to recognize the data type

    print (df.dtypes)


    to see the type of my data, after ...

    df.at[Rw+1,'Alpha']=x1


    My code is:

    for Rw in range(25):
    def adj(df):
    R=float(df.iloc[Rw,1])
    V=float(df.iloc[Rw+1,1])

    if R>=V:
    x1=R-V
    else:
    x2=(V-R)**3

    df.at[Rw+1,'Alpha']=x1
    print (df.dtypes)
    df.at[Rw+1,'Beta']=x2
    adj(df)


    I get an Error:

    AttributeError: 'float' object has no attribute 'dtypes'


    I'm afraid that lines with .at[ _ ] in the loop, are not represents float64 types.

    How can i be sure or how can i change to float64 or how can i add these "Alpha" and "Beta" to my DataFrame? ...i am using python27.

    Login To add answer/comment
     

Share This Page