Skip to content

Instantly share code, notes, and snippets.

@debonx
Created November 1, 2018 11:53
Show Gist options
  • Save debonx/8893050e5b35c041da561b0977f865a8 to your computer and use it in GitHub Desktop.
Save debonx/8893050e5b35c041da561b0977f865a8 to your computer and use it in GitHub Desktop.
Using Numpy example. Records of weekly weather temperatures. More at www.numpy.org.
import numpy as np
#Get data from CSV
#Temperatures recorded 4 times a day, at 0:00, 6:00, 12:00, and 18:00. Last weeks data (Monday through Friday)
temperatures = np.genfromtxt('temperature_data.csv', delimiter=',')
#Adjust temperatures
temperatures_fixed = temperatures + 3.0
#Select Monday's Temperatures
monday_temperatures = temperatures_fixed[0,:]
#Select Thursday / Friday Temperatures
thursday_friday_morning = temperatures_fixed[3:,1]
#Select Extremes
temperature_extremes = temperatures_fixed[(temperatures_fixed < 50) | (temperatures_fixed > 60)]
#Print data
print(temperature_extremes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment