The code which I am running takes an input from a file and reads it as a dataframe. Each line in the data file contains a long expression. for example, it looks roughly something like this (with about half a million more entries):
(((kshA-kslB)/(ZA*ZB))*abs((kshA/rdA)-(kshB/rpB))) corr= 0.9514
(((eaA+kslB)+abs(eaA-eaB))/((ZA*rpB)*abs(rpB-rsB))) corr= 0.9504
((abs(enA-enB)+abs(kslA-kslB))/((ZA*ZB)*(rpB*rsA))) corr= 0.9502
I read each line of that dataframe and take the first column of it. Further, I convert it into a string (f = str(df.iloc[i])
, i
being the loop counter). [I need to do it as i will be using eval()
to evaluate the string and also replace a few expressions.] Now, here I face two issues:
a. f
, when printed gives an output like
0 (((eaA+kslB)+abs(eaA-eaB))/((ZA*rsB)*abs(rpB)))
Name: 0, dtype: object
Cant I get the output with just expression [(((eaA+kslB)+abs(eaA-eaB))/((ZA*rsB)*abs(rpB)))
] ? (I have no idea where the 0
comes from!)
b. Whenever the length of this output crosses 77 characters, it implicitly converts the expression into something like this (((kshA-kslB)/(ZA*ZB))*abs((kshA/rdA)-(kshB/rp...
which gives me an error while evaluating it further.
Anyone has any idea where things are going wrong?
edit 1: This is what i get when i do df.head(). Note the ones ending with ...
are the one which have in excess of 77 characters.
0 (((eaA+kslB)+abs(eaA-eaB))/((ZA*rsB)*abs(rpB)))
1 (((kshA-kslB)/(ZA*ZB))*abs((kshA/rdA)-(kshB/rp...
2 (((eaA+kslB)+abs(eaA-eaB))/((ZA*rpB)*abs(rpB-r...
3 ((abs(enA-enB)+abs(kslA-kslB))/((ZA*ZB)*(rpB*r...
4 (((eaA*rdB)-(rsB*kshB))/((rpB)^3*(ZA*eaB)))