I have a csv file with the contents:
StrainMax 0.125
StrainMin -0.125
cycles_sec 10
time_percent 50
I read it in with:
df = pd.read_csv('Strains_SI.csv', index_col=None, header=None)
Then this:
StrainMax = df.iat[0,0]
StrainMin = df.iat[1,0]
cycles_sec = df.iat[2,0]
time_percent = df.iat[3,0]
print(StrainMax)
print(StrainMin)
print(cycles_sec)
print(time_percent)
And what I get is this (I believe these are strings):
StrainMax 0.125
StrainMin -0.125
cycles_sec 10
time_percent 50
But what I want is this:
0.125 (I want an float here)
-0.125 (I want an float here)
10 (I want an integer here)
50 (I want an integer here)
Is this possible?
I tried numerous Pandas commands and can't get it. I am expecting floats and integers of the numbers only.
source https://stackoverflow.com/questions/76301629/pandas-issue-pulling-a-number-from-a-string-input-from-a-csv-file
Comments
Post a Comment