0
I need to add the value of the lines in which appears "Resposnsável C', in a practical way I need to add lines 3, 4 and 9 from column 2, the result should be 112. So far I’ve been able to print the lines I want using iloc, but I can’t add them. Follow the code. ps: I need to add what is in red.
import pandas as pd
def trans_excel_py(arquivocsv):
df = pd.read_csv(arquivocsv, sep=';', header = None)
return df
def soma_colunas(arquivocsv):
df = pd.read_csv(arquivocsv, sep=';')
matriz = pd.DataFrame(df.values)
somas = []
for i in range(len(matriz)):
Total = matriz[i].sum()
somas.append(Total)
return somas
teste = trans_excel_py('cronograma.csv')
print(teste)
teste_sum = soma_colunas("cronograma.csv")
df = pd.DataFrame([teste_sum[2:10]],columns=['S1', 'S2', 'S3','S4','S5','S6','S7','S8'])
print("\n",df)
print(sum(teste_sum[2:10]))
df1 = teste.iloc[[3,4,9]]
print("\n",df1)
Unfortunately it did not work, it did not return any result... It is not that it is wrong it just does not return the sum of what is in red. I tried with only one line (the 3 that should return me the answer of the sum as 24) but in the end it resulted me as 0.0. To be more specific I don’t want the sum of the whole row, just the sum of the row going from column 2 to column 9.
– Gi Muniz