-
Notifications
You must be signed in to change notification settings - Fork 9
/
Python Data Analysis Intro.py
71 lines (44 loc) · 1.03 KB
/
Python Data Analysis Intro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <markdowncell>
# ## Python For Data Analysis
#
# 1. Loading Data
# 2. Trendlines
# 3. Statistical Analysis
# 4. Why Script?
# <codecell>
from science import *
# <markdowncell>
# http://data.giss.nasa.gov/gistemp/station_data/
# <codecell>
data=pandas.read_csv('temperature_data/johnstown.txt', delimiter=r"\s+")
data.head()
# <codecell>
year,temp=data['YEAR'],data['metANN']
# <codecell>
plot(year,temp,'-o')
# <codecell>
temp[temp>900]=NaN
# <codecell>
plot(year,temp,'-o')
# <codecell>
plot(year,temp,'-o')
xlabel('Year')
ylabel('Temperature (C)')
# <codecell>
def plot_temperature_data(fname):
data=pandas.read_csv(fname, delimiter=r"\s+")
year,temp=data['YEAR'],data['metANN']
temp[temp>900]=NaN
figure()
plot(year,temp,'-o')
xlabel('Year')
ylabel('Temperature (C)')
title(fname)
# <codecell>
from glob import glob
fnames=glob('temperature_data/*.txt')
for fname in fnames:
plot_temperature_data(fname)
# <codecell>