From e03932b2619a1827090ea2b33c6d9370c166cce6 Mon Sep 17 00:00:00 2001 From: vsanders Date: Thu, 25 Oct 2018 14:12:46 -0400 Subject: [PATCH 1/2] Added file for problem #1 --- #1.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 #1.py diff --git a/#1.py b/#1.py new file mode 100644 index 0000000..0a52faa --- /dev/null +++ b/#1.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Oct 25 13:48:30 2018 + +@author: vysan +""" + +import pandas as pd +def oddrows(filename): + data=pd.read_csv(filename,header=0,sep=",") + return data.iloc[1::2] +print oddrows("filename") #filename is the name of the file with your dataframe + + + + + From 9aca0c625dda98ce0479a88b5b6a1a4c63f3b2c6 Mon Sep 17 00:00:00 2001 From: vsanders Date: Thu, 25 Oct 2018 16:25:08 -0400 Subject: [PATCH 2/2] Added file for problem #2 --- #2.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 #2.py diff --git a/#2.py b/#2.py new file mode 100644 index 0000000..130ac22 --- /dev/null +++ b/#2.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Oct 25 14:15:49 2018 + +@author: vysan +""" +#return number of observations for given species +import pandas as pd +data=pd.read_csv("iris.csv",header=0,sep=",") +def count(name): + return (data["Species"]==name).sum() +count("name") #name is the name of the species of interest + + + +#return dataframe for flowers with Sepal.Width > than specified value +import pandas as pd +data=pd.read_csv("iris.csv",header=0,sep=",") +def sepalwidthgreaterthan(x): + return data[data["Sepal.Width"] > x] +sepalwidthgreaterthan(x) #x is the specified value by the user + + + +#write data for given species to comma-delimited file +#with name "speciesname".csv +import pandas as pd +data=pd.read_csv("iris.csv",header=0,sep=",") +def newfilefor(name): + new=data[data["Species"]==name] + new.to_csv(str(name)+".csv",sep=(",")) +newfilefor("name") #name is the name of the given species + + +