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:
76
76
## [ Data Science] ( /data_science/ )
77
77
- [ Load CSV into a pandas dataframe] ( /data_science/load_csv.py )
78
78
- [ 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
79
80
80
81
## Databases
81
82
- [ 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
6
6
7
7
- [ Load CSV into a pandas data frame] ( /data_science/load_csv.py ) Load data from the outside world
8
8
- [ 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
9
10
10
11
** [ 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