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

End the "Making Choices" lesson with an example that synthesizes what has been learned up to that point #293

jdidion opened this issue Aug 3, 2016 · 0 comments


Copy link

@jdidion jdidion commented Aug 3, 2016

Let's combine what we've learned about searching for files (glob), reading in data (numpy.loadtxt), iterating over sequences (for loops), and making choices (if statements) to check all of our data files in a single loop:

for datafile in glob.glob('data/inflammation*.csv'):
data = numpy.loadtxt(fname=datafile, delimiter=',')
if numpy.max(data, axis=0)[0] == 0 and numpy.max(data, axis=0)[20] == 20:
print('Suspicious looking maxima!')
elif numpy.sum(numpy.min(data, axis=0)) == 0:
print('Minima add up to zero!')
print('Seems OK!')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.