I am simply trying to get the sum of a column ('Value') in a dataframe in python. I believe I am creating the dataframe, but I am not sure. I am getting a result back, however, it's not the result I imagine when it comes to .sum().
import csv
import pandas as pd
with open('new_taste.csv', 'r') as csv_trades:
csv_reader = csv.DictReader(csv_trades)
df = pd.DataFrame(data=csv_reader)
total = df['Value'].sum()
df.loc['Value'] = pd.Series(df['Value'].sum(), index=['Value'])
print(df['Value'])
is giving me
0 133
1 180
2 -117
3 -159
4 1
...
316 14
317 14
318 19
319 18
Value 133180-117-15911-84-3-10-23434245-23-3085-5241...
Name: Value, Length: 321, dtype: object
I noticed it's bringing back every number, not the sum of the numbers. I would like to bring back the sum.
total
to hold the sum, but then recalculate it anyway.