Hello Everyone! Thanks for clicking on this video. If you find it difficult to see please please check out this video here where I zoom in on the text ruclips.net/video/YEkqaJSZzNg/видео.html
Hi Kofi, We can select which rows we want to sum using iloc. Here is an example df['sum_some_rows'] = df.iloc[0:3].sum(axis=1) Here we just past the index location of the rows that we want to sum to iloc. In the above example we are say get the sum in for rows 0, 1, &, 2 (up to but not including three). If you wanted to sum the last 5 rows we could use .iloc[-5:] or if we wanted to sum rows at index 2 through 6 we could use .iloc[2:7]
Hi Brenden, thanks! I agree it is hard to see if especially if you are not on a computer. I have updated this video with larger text to improve visibility. ruclips.net/video/YEkqaJSZzNg/видео.html
A common error is *TypeError: can only concatenate str (not "int") to str* . This means that some of your data in the column (or row) that you are trying to sum contains both strings and integers/floats. If this is the case you can convert your column to all numeric values. This video provides a detailed explanation on how to do that ruclips.net/video/evKYySLSzyk/видео.html Once all your values are converted to numeric this TypeError should go away.
Wow, I'm impressed you could get your screen under a microscope!! 😄 Being serious though, I agree, it is really small. I actually made this updated video that is easier to see ruclips.net/video/YEkqaJSZzNg/видео.html
Hello Everyone! Thanks for clicking on this video. If you find it difficult to see please please check out this video here where I zoom in on the text ruclips.net/video/YEkqaJSZzNg/видео.html
Great video. I was after this particular topic.
Thanks, awesome video bro!
Very informative! Please make more videos like this.
thank you!!! simple !
Great video, thanks.
How do we sum some rows and not all the rows?
Hi Kofi,
We can select which rows we want to sum using iloc. Here is an example
df['sum_some_rows'] = df.iloc[0:3].sum(axis=1)
Here we just past the index location of the rows that we want to sum to iloc. In the above example we are say get the sum in for rows 0, 1, &, 2 (up to but not including three).
If you wanted to sum the last 5 rows we could use .iloc[-5:]
or if we wanted to sum rows at index 2 through 6 we could use .iloc[2:7]
in the fist example, need to know how to add new row at the end and have a sum result
Is this what you are looking for? This will add the column sums as a new row to the end of the DataFrame.
df.loc[len(df)] = df.sum(axis=0)
Wow
Great video. Thank you. However, videos are too small to see what you are coding.
Hi Brenden, thanks! I agree it is hard to see if especially if you are not on a computer. I have updated this video with larger text to improve visibility.
ruclips.net/video/YEkqaJSZzNg/видео.html
it's not working for the data loaded from csv.
What error message are you getting?
A common error is *TypeError: can only concatenate str (not "int") to str* . This means that some of your data in the column (or row) that you are trying to sum contains both strings and integers/floats. If this is the case you can convert your column to all numeric values. This video provides a detailed explanation on how to do that ruclips.net/video/evKYySLSzyk/видео.html Once all your values are converted to numeric this TypeError should go away.
screen is too small, have to use microscope
Wow, I'm impressed you could get your screen under a microscope!! 😄 Being serious though, I agree, it is really small. I actually made this updated video that is easier to see ruclips.net/video/YEkqaJSZzNg/видео.html