In [4]:
import glob
# The glob library contains a single function, also called glob,
# that finds files whose names match a pattern.
In [5]:
print(glob.glob('data/inflammation*.csv'))
This is has created a list with values of filenames that matched the glob above.
In [6]:
# Lets load two libraries
import numpy # Fundamental package for scientific computing with Python.
import matplotlib.pyplot # Provides a MATLAB-like plotting framework.
# this allows plots to appear directly in the notebook
%matplotlib inline
In [7]:
filenames = glob.glob('data/inflammation*.csv')
filenames = filenames[0:3]
In [8]:
filenames
Out[8]:
In [9]:
for f in filenames:
print(f)
In [10]:
for f in filenames:
print(f)
data = numpy.loadtxt(fname=f, delimiter=',') # load the data in to into the data variable
fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0)) # create a plotting figure
axes1 = fig.add_subplot(1, 3, 1)
axes2 = fig.add_subplot(1, 3, 2)
axes3 = fig.add_subplot(1, 3, 3)
axes1.set_ylabel('average')
axes1.plot(data.mean(axis=0))
axes2.set_ylabel('max')
axes2.plot(data.max(axis=0))
axes3.set_ylabel('min')
axes3.plot(data.min(axis=0))
fig.tight_layout()
matplotlib.pyplot.show()
In [1]:
def fahr_to_kelvin(temp):
return ((temp - 32) * (5/9)) + 273.15
In [2]:
fahr_to_kelvin(100)
Out[2]:
In [3]:
fahr_to_kelvin(60)
Out[3]:
In [9]:
def kelvin_to_celsius(temp_k):
return temp_k - 273.15
In [10]:
kelvin_to_celsius(310.92777777777775)
Out[10]:
In [4]:
def print_hello_world():
print("Hello World")
print("Hello everybody")
In [5]:
print_hello_world()
In [7]:
def print_hello_name(name):
print("Hello %s" % name)
In [8]:
print_hello_name("Andre")
In [11]:
def get_value_from_input(value):
if value < 10:
return value
else:
return value * 10
In [12]:
x = get_value_from_input(5)
x
Out[12]:
In [13]:
y = get_value_from_input(15)
In [14]:
y
Out[14]:
In [ ]: