-
Notifications
You must be signed in to change notification settings - Fork 10
Buynak-Yingying Tutorial 6 #6
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
Open
mbuynak
wants to merge
4
commits into
lyy005:master
Choose a base branch
from
mbuynak:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Question 1-method 1-use groupby and apply function | ||
| import pandas as pd | ||
| import matplotlib.pyplot as plt | ||
| data=pd.read_table("/Users/chenyingying/Documents/Intro_Biocom_ND_319_Tutorial6/UWvMSU_1-22-13.txt") | ||
| data['cumulative score']=data.iloc[:,2] | ||
| data['cumulative score']=data.groupby('team')['cumulative score'].apply(lambda x: x.cumsum()) | ||
| # Plot | ||
| fig,ax=plt.subplots(figsize=(8,6)) | ||
| ax.set_xlabel('Time') | ||
| ax.set_ylabel('Score') | ||
| data.groupby('team')['cumulative score'].plot(legend=True) | ||
|
|
||
|
|
||
| # Question 1-method 2-use for loop and if function | ||
| import pandas as pd | ||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| data=pd.read_table("/Users/chenyingying/Documents/Intro_Biocom_ND_319_Tutorial6/UWvMSU_1-22-13.txt") | ||
| data['UWscore']=data.iloc[:,2] | ||
| data['UWtemp']=data.iloc[:,2] | ||
| data['MSUscore']=data.iloc[:,2] | ||
| data['MSUtemp']=data.iloc[:,2] | ||
| data.loc[data['team']=='MSU','UWscore']=np.nan | ||
| data.loc[data['team']=='MSU','UWtemp']=0 | ||
| data.loc[data['team']=='UW','MSUscore']=np.nan | ||
| data.loc[data['team']=='UW','MSUtemp']=0 | ||
| data.head(n=10) | ||
| for i in range (0,len(data.index)): | ||
| if np.isnan(data.iloc[i,3])==False: | ||
| data.iloc[i,3]=data.iloc[0:i+1,4].sum() | ||
| if np.isnan(data.iloc[i,5])==False: | ||
| data.iloc[i,5]=data.iloc[0:i+1,6].sum() | ||
| # Plot | ||
| fig,ax=plt.subplots(figsize=(8,6)) | ||
| ax.set_xlabel('Time') | ||
| ax.set_ylabel('Score') | ||
| x1=data.loc[np.isfinite(data['UWscore']),'time'] | ||
| x2=data.loc[np.isfinite(data['MSUscore']),'time'] | ||
| plt.plot(x1, data['UWscore'].dropna(),label="UW") | ||
| plt.plot(x2, data['MSUscore'].dropna(),label="MSU") | ||
| plt.legend() | ||
|
|
||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import pandas | ||
| import numpy | ||
|
|
||
| #this is a guess the number game | ||
| import random | ||
|
|
||
| guessesTaken=0 | ||
|
|
||
| print('Hello! What is your name?') | ||
| myName=input() | ||
|
|
||
| number=random.randint(1,100) | ||
| print('Well,'+ myName +',I am thinking of a number between 1 and 100.') | ||
|
|
||
| while guessesTaken < 10: | ||
| print('Take a guess') | ||
| guess=input() | ||
| guess=int(guess) | ||
|
|
||
| guessesTaken=guessesTaken + 1 | ||
|
|
||
| if guess < number: | ||
| print('Your guess is too low.') | ||
|
|
||
| if guess > number: | ||
| print('Your guess is too high.') | ||
|
|
||
| if guess == number: | ||
| guessesTaken= str(guessesTaken) | ||
| print('Good job,' + myName +'!You guessed my number in' + guessesTaken +'guesses!') | ||
|
|
||
| if guess != number: | ||
| number= str(number) | ||
| print('Nope. The number I was thinking of was ' +number) | ||
|
|
||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job