Example of CMR in Apache Zeppelin using FRED S&P500 Case Shiller US National Home Price Index

Setup:

This example is running on an Apple Mac OSX — in the ~/.bash_profile, add the following lines:

export SPARK_HOME=/Users/…/…/spark-2.3.0-bin-hadoop2.7/
export SPARK_SUBMIT_OPTIONS=”–packages com.coherentlogic.cmr.api:cmr-api-core:2.0.2.1-RELEASE,dom4j:dom4j:1.6.1,com.fasterxml.jackson.core:jackson-databind:2.9.6 –exclude-packages junit:junit,org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.0_spec,org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec,org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec,javax.activation:activation,net.jcip:jcip-annotations,org.jboss.logging:jboss-logging-annotations,org.jboss.logging:jboss-logging-processor”

The Example:

import com.coherentlogic.cmr.api.builders.CMR
import com.coherentlogic.cmr.fred._
val FRED_API_KEY = System.getenv(“FRED_API_KEY”) // See here to acquire your own.
val cmr = new CMR ()
val sp500CaseShillerUSNationalHomePriceIndexDS = cmr.fred.series.observations.withApiKey(FRED_API_KEY).withSeriesId(“CSUSHPINSA”).doGetAsObservationsDataset(spark)
sp500CaseShillerUSNationalHomePriceIndexDS.show

The Result:

A picture of CMR used to acquire S&P-500 Case-Shiller US National Home Price Index data while running in Apache Zeppelin.