# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/davidjustin1974/DS-Unit-1-Sprint-1-Dealing-With-Data/blob/master/module1-afirstlookatdata/LS_DS_111_A_First_Look_at_Data.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="Okfr_uhwhS1X" colab_type="text"
# # Lambda School Data Science - A First Look at Data
#
#

# + [markdown] id="9dtJETFRhnOG" colab_type="text"
# ## Lecture - let's explore Python DS libraries and examples!
#
# The Python Data Science ecosystem is huge. You've seen some of the big pieces - pandas, scikit-learn, matplotlib. What parts do you want to see more of?

# + id="WiBkgmPJhmhE" colab_type="code" outputId="b8ccef7f-3719-480e-f1fe-4275cf359c2d" colab={"base_uri": "https://localhost:8080/", "height": 34}
# TODO - we'll be doing this live, taking requests
# and reproducing what it is to look up and learn things
1 + 1
print("this is a change")

# + [markdown] id="lOqaPds9huME" colab_type="text"
# ## Assignment - now it's your turn
#
# Pick at least one Python DS library, and using documentation/examples reproduce in this notebook something cool. It's OK if you don't fully understand it or get it 100% working, but do put in effort and look things up.

# + id="TGUS79cOhPWj" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 298} outputId="68a82311-3beb-4d83-f428-1d3e28ef009a"
# TODO - your code here
# Use what we did live in lecture as an example

# %matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig

N = 128 # number of samples
M = 7 # number of sample functions

# generate random signal
np.random.seed(1)
x = np.random.normal(size=(M, N))
h = sig.firwin2(N, [0, .4, .42, .65, .67, 1],[0,0,1,1,0,0])
x = [np.convolve(xi, h, mode='same') for xi in x]

#DFT of signal
X = np.fft.rfft(x, axis=1)
Om = np.linspace(0, np.pi, X.shape[1])

# plot signal and its spectrum
plt.figure(figsize=(10,4))
plt.plot(Om, np.abs(X.T))
plt.title("Magnitude Spectrum")
plt.xlabel(r'$\Omega[\mu]$')
plt.ylabel(r'$|X[\mu]|$')
plt.axis([0, np.pi, 0, 30]);

# The original example had 256 samples.
# I cut the number of samples in half, tripled it, etc.
# I worked with various ouptuts after the import.
# The original number of sample functions was 5.

# + [markdown] id="BT9gdS7viJZa" colab_type="text"
# ### Assignment questions
#
# After you've worked on some code, answer the following questions in this text block:
#
# 1.  Describe in a paragraph of text what you did and why, as if you were writing an email to somebody interested but nontechnical.
#
# 2.  What was the most challenging part of what you did?
#
# 3.  What was the most interesting thing you learned?
#
# 4.  What area would you like to explore with more time?
#
#
#

# + [markdown] id="tdKGs9VzmseH" colab_type="text"
# 1.  I followed the YouTube video from this morning's lecture.  I found a Python Library that was edited in the last year.  Python Libraries that were five years or older had difficulties being imported into CoLab.  Once I had imported the Magnitude Spectrum into CoLab, I entered the code in manually and adjusted the sample size and number of sample functions in LS_DS_111_A so that my work could be reviewed.
#
# 2.  Importing a library that worked into CoLab.  Dakota helped me out with "!pip install" codes on the first two imports.  I had some issues with typing in the plt.xlabel and plt.ylabel codes.  The ' ' between the r and $ were not being recongized at the end of the code.  I had to copy and paste those two lines of code instead of typing them in.
#
# 3.  That there are going to be libraries that need assistance being imported in order to get them to operate properly.  It will be nice to find libraries that already perform specific functions so that you don't have to reinvent the wheel from scratch every time you write a program to analyze data.  
#
# 4.  I'm interested in finding any key indicators of recession and the amount of time between the indicator and the bottom of a market.  I analyzed data from the St. Louis Federal Reserve website and I can tell you that we are on the clock for the next recession.  I would like to analyze data about treasury rate inversion dates and when the housing market bottoms out.  I've already figured out the time frame from when the stock market will bottom out after treasury rate inversion dates occur.  The last recession officially started in December 2007 and the stock market bottomed out in March 2009.  It appears - but I have not confirmed - that the housing market bottomed out in 2011.  I'd like to see if there is a pattern for the housing market bottoming out in the same fashion that the stock market bottomed out in the last five recessions.

# + [markdown] id="_XXg2crAipwP" colab_type="text"
# ## Stretch goals and resources
#
# Following are *optional* things for you to take a look at. Focus on the above assignment first, and make sure to commit and push your changes to GitHub (and since this is the first assignment of the sprint, open a PR as well).
#
# - [pandas documentation](https://pandas.pydata.org/pandas-docs/stable/)
# - [scikit-learn documentation](http://scikit-learn.org/stable/documentation.html)
# - [matplotlib documentation](https://matplotlib.org/contents.html)
# - [Awesome Data Science](https://github.com/bulutyazilim/awesome-datascience) - a list of many types of DS resources
#
# Stretch goals:
#
# - Find and read blogs, walkthroughs, and other examples of people working through cool things with data science - and share with your classmates!
# - Write a blog post (Medium is a popular place to publish) introducing yourself as somebody learning data science, and talking about what you've learned already and what you're excited to learn more about.

StarcoderdataJupyterScriptsDedupFiltered