SUM COLUMNS & ROWS IN A DATAFRAME | How to sum columns and rows in a Pandas DataFrame

  Рет қаралды 21,264

Chart Explorers

Chart Explorers

Күн бұрын

Пікірлер
@ChartExplorers
@ChartExplorers 3 жыл бұрын
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 kzbin.info/www/bejne/j3bOopSAiL-thMk
@Zenoandturtle
@Zenoandturtle Жыл бұрын
Great video. I was after this particular topic.
@brooklynjames4423
@brooklynjames4423 4 жыл бұрын
Very informative! Please make more videos like this.
@chrisbagshaw5676
@chrisbagshaw5676 4 жыл бұрын
Thanks, awesome video bro!
@joegalbraith1585
@joegalbraith1585 4 жыл бұрын
Great video, thanks.
@Diego_-
@Diego_- 4 жыл бұрын
thank you!!! simple !
@kofiasante9477
@kofiasante9477 3 жыл бұрын
How do we sum some rows and not all the rows?
@ChartExplorers
@ChartExplorers 3 жыл бұрын
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]
@janats8727
@janats8727 4 жыл бұрын
it's not working for the data loaded from csv.
@ChartExplorers
@ChartExplorers 4 жыл бұрын
What error message are you getting?
@ChartExplorers
@ChartExplorers 4 жыл бұрын
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 kzbin.info/www/bejne/m6euiqyJgbitr80 Once all your values are converted to numeric this TypeError should go away.
@lijithmohanan928
@lijithmohanan928 4 жыл бұрын
in the fist example, need to know how to add new row at the end and have a sum result
@ChartExplorers
@ChartExplorers 4 жыл бұрын
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)
@brendensong8000
@brendensong8000 4 жыл бұрын
Great video. Thank you. However, videos are too small to see what you are coding.
@ChartExplorers
@ChartExplorers 4 жыл бұрын
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. kzbin.info/www/bejne/j3bOopSAiL-thMk
@ceritamenarikk
@ceritamenarikk 3 жыл бұрын
screen is too small, have to use microscope
@ChartExplorers
@ChartExplorers 3 жыл бұрын
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 kzbin.info/www/bejne/j3bOopSAiL-thMk
@harshitagupta5372
@harshitagupta5372 3 ай бұрын
Wow
How to filter a pandas DataFrame | 6 HELPFUL METHODS
17:27
Chart Explorers
Рет қаралды 31 М.
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
How do I apply a function to a pandas Series or DataFrame?
17:58
Data School
Рет қаралды 203 М.
How do I select multiple rows and columns from a pandas DataFrame?
21:47
When should I use a "groupby" in pandas?
8:25
Data School
Рет қаралды 246 М.
Automate Excel Work with Python and Pandas
21:29
John Watson Rooney
Рет қаралды 100 М.
Add New Columns To Dataframe - Pandas For Machine Learning 6
8:41