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

Lara Chalas #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions Exercise7hw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 12 11:31:15 2018

@author: saurylara
"""


#Import the wages file
import pandas
wages = pandas.read_csv("/Users/saurylara/Desktop/wages.csv")

#Create function that returns odd rows of any pandas dataframe
def odder (filename):
headfile = filename[1: :2]
return headfile

print(odder(wages))

#Import the iris file
iris = pandas.read_csv("/Users/saurylara/Desktop/IBC_EX6/iris.csv")

#Create function that returns the number of observations of a species for given dataset
def observer (filename,speciesname):
numobservations= filename[filename['Species']==speciesname].count()['Species']
return numobservations

print(observer(iris,"setosa"))

#Create function that returns a dataframe for flowers with Sepal.Width greater than specified value
def dataframe (filename, widthvalue):
numSepalWidth = iris[iris['Sepal.Width'] > widthvalue]
return numSepalWidth

print(dataframe(iris,3.0))

#Create function that writes data for given species to comma-deliminated file with given species name as the file name
def dataredirector (filename, speciesname):
dataSpecies = iris[iris['Species']==speciesname]
dataSpecies.to_csv(speciesname+'.csv')
return 0

dataredirector(iris,"virginica")