I am trying to insert a series of floats into a new Dataframe (for future manipulation and for easier visual comparison of values). The code runs without error, and the table is output, but my floats come up as NaN. If I print the float, the correct number is output, so I know the number exists.
This is what the floats look like (there are many more of them):
total_pressure_at_100_for_80 = tem80df['pressure80'][0:103].sum()
total_pressure_at_100_for_100= tem100df['pressure100'][0:103].sum()
They're just the sum of a column(pressure##) in a dataframe (tem##) and I'm trying to sum the first 103 rows. I just want to insert the value of the sum into a new Dataframe. This is what I've got:
data = {'Depth used for calculation': ['80','100', '120', '140', '160','180'],
'Data from tem80': [total_pressure_at_80_for_80, total_pressure_at_100_for_80, total_pressure_at_120_for_80, total_pressure_at_140_for_80, total_pressure_at_160_for_80, total_pressure_at_180_for_80]}
df = pd.DataFrame (data, columns = ['Depth used for calculation', ' Data from tem80'])
print(df)
This is what I get:
Depth used for calculation Data from tem80
0 80 NaN
1 100 NaN
2 120 NaN
3 140 NaN
4 160 NaN
5 180 NaN
Any help would be appreciated.
question from:
https://stackoverflow.com/questions/65915458/inserting-floats-into-new-dataframe-and-getting-nan 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…