File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ Here's what you can find here:
7676## [ Data Science] ( /data_science/ )
7777 - [ Load CSV into a pandas dataframe] ( /data_science/load_csv.py )
7878 - [ Group data and then find statistics for each group] ( /data_science/stats_by_group.py )
79+ - [ Sum every column] ( /data_science/sum_columns.py ) Load data and sum all columns
7980
8081## Databases
8182 - [ Neo4j] ( /databases/neo4j/ )
Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ Data science uses computer science and math to extract knowledge and information
66
77 - [ Load CSV into a pandas data frame] ( /data_science/load_csv.py ) Load data from the outside world
88 - [ Group data and then find statistics for each group] ( /data_science/stats_by_group.py ) Perform aggregate calculations on subsets of the data
9+ - [ Sum every column] ( /data_science/sum_columns.py ) Load data and sum all columns
910
1011 ** [ Back to start] ( https://github.com/ccozad/python-playground ) **
Original file line number Diff line number Diff line change 1+ import pandas as pd
2+
3+ # Put your own CSV file name here
4+ df = pd .read_csv ('tshirts.csv' )
5+
6+ numeric_columns = df .select_dtypes (include = [int , float ])
7+ column_sums = numeric_columns .sum (axis = 0 )
8+
9+ # Remove the integer cast if you want to deal with floats
10+ column_sums = column_sums .astype (int )
11+ print (column_sums )
You can’t perform that action at this time.
0 commit comments