Skip to content

Instantly share code, notes, and snippets.

@josecastillolema
Last active February 28, 2025 17:18
Show Gist options
  • Save josecastillolema/2d32db389bebcc03e662898026cd497c to your computer and use it in GitHub Desktop.
Save josecastillolema/2d32db389bebcc03e662898026cd497c to your computer and use it in GitHub Desktop.
iffe_solutions

Lab 1 - S3

  • SELECT s._1, s._3 FROM s3object s
  • SELECT count(*) FROM s3object s WHERE s._7='NY'

Lab 3 - Athena

  • SELECT customerID, last_name from american_customers
  • SELECT count(*) FROM american_customers WHERE state='NY'
  • CREATE TABLE american_customers_norm AS
      SELECT customerid,first_name,last_name,street_address,city,state,phone,
           date_parse(join_date,'%m/%d/%Y') as join_date_norm
      FROM american_customers
  • SELECT * FROM american_customers_norm
      WHERE join_date_norm >= to_timestamp('01-01-2014', 'dd-mm-yyyy')
  • DROP DATABASE customers CASCADE

Lab 4 - Glue

  • SELECT customerID, "last name" from imported_data

Lab 5 - Reshift

  • CREATE TABLE american_customers_norm AS
      SELECT customerid,first_name,last_name,street_address,city,state,phone,
             to_date(join_date,'MM/DD/YYYY') as join_date_norm
      FROM american_customers
  • SELECT * FROM american_customers_norm
      WHERE join_date_norm >= to_timestamp('01-01-2014', 'dd-mm-yyyy')

Lab 6 - Sagemaker

  • from bokeh.plotting import figure, show
    from bokeh.io import output_notebook
    
    state_counts = df['State'].value_counts()
    
    p = figure(x_range=state_counts.index.tolist(), title="Histograma de Estados", x_axis_label='Estados', y_axis_label='Frecuencia')
    p.vbar(x=state_counts.index, top=state_counts.values, width=0.5, color='navy')
    p.xaxis.major_label_orientation = 1.2
    
    output_notebook()
    show(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment