Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanders #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions #1.py
Original file line number Diff line number Diff line change
@@ -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





35 changes: 35 additions & 0 deletions #2.py
Original file line number Diff line number Diff line change
@@ -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