Learn practical skills, build real-world projects, and advance your career
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import tensorflow as tf
print(tf.__version__)
2.3.0
import numpy as np
import matplotlib.pyplot as plt
def plot_series(time, series, format="-", start=0, end=None):
    plt.plot(time[start:end], series[start:end], format)
    plt.xlabel("Time")
    plt.ylabel("Value")
    plt.grid(True)
!wget --no-check-certificate \
    https://storage.googleapis.com/laurencemoroney-blog.appspot.com/Sunspots.csv \
    -O /tmp/sunspots.csv
--2020-10-01 15:15:15-- https://storage.googleapis.com/laurencemoroney-blog.appspot.com/Sunspots.csv Resolving storage.googleapis.com (storage.googleapis.com)... 64.233.166.128, 74.125.133.128, 74.125.140.128, ... Connecting to storage.googleapis.com (storage.googleapis.com)|64.233.166.128|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 70827 (69K) [application/octet-stream] Saving to: ‘/tmp/sunspots.csv’ /tmp/sunspots.csv 100%[===================>] 69.17K --.-KB/s in 0.001s 2020-10-01 15:15:15 (82.9 MB/s) - ‘/tmp/sunspots.csv’ saved [70827/70827]
import csv
time_step = []
sunspots = []

with open('/tmp/sunspots.csv') as csvfile:
  reader = csv.reader(csvfile, delimiter=',')
  next(reader)
  for row in reader:
    sunspots.append(float(row[2]))
    time_step.append(int(row[0]))

series = np.array(sunspots)
time = np.array(time_step)
plt.figure(figsize=(10, 6))
plot_series(time, series)
Notebook Image