Goal : Conduct exploratory data analyzes on publicly available datasets using Ta
ID: 3599855 • Letter: G
Question
Goal: Conduct exploratory data analyzes on publicly available datasets using Tableau
Dataset: You will be working with 311’s open data available from NYC’s Open Data initiative. Filter and download for only first 6 months of 2017 i.e. from 1/1/2017 to 6/30/2017. This file will be around 700-800mb so it may take a while depending upon your connection.
Tasks:
Also download the data dictionary file to know more about each field
Import the dataset in Tableau and clean and process it as needed.
Explore the data by analyzing a few individual variables (both categorical and continuous i.e. dimensions and measures) to understand what it’s about.
Once you are comfortable with the contents of the dataset, pick one agency that has at least a few thousand records for further investigation.
Identify a minimum of five questions containing at least 2-3 variables. Make sure at least two of the questions include calculated variables.
Before you start creating visualizations, think of the various questions that this dataset can answer and then proceed to creating visualizations. This dataset is quite rich in terms of its variety of data types: We have temporal (time-based) data, geographic location data, and categorical data. Because of this, there are many ways one could choose to visualize this dataset. Here are a few (low-hanging fruit) examples. You want to try out more than one approach:
i.Some ideas include how response time varies by complaint type, are certain complaints common in some zip codes but not in others? Are certain types of complaints prevalent near school zones? Trend in complaint statistics over period of time across multiple categories or locations? Etc.…
Explanation / Answer
package com;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Random;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.JFrame;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.border.EtchedBorder;
class GlobalVariables {
public ArrayList<Fish> mFish;
public FishTank mFishTank;
private GlobalVariables() {
mFish = new ArrayList<Fish>();
mFishTank = new FishTank();
}
private static GlobalVariables instance;
public static GlobalVariables getInstance() {
if (instance == null){
instance = new GlobalVariables();
}
return instance;
}
}
class Fish implements Comparable<Fish>{
int mX;
int mY;
int mId;
Color mColor;
public Fish(int id, int x, int y, Color color){
mId = id;
mX = x;
mY = y;
mColor = color;
}
public void paint(Graphics g){
// Implement this function
}
public void move(){
// Implement this function
}
@Override
public int compareTo(Fish o) {
return mId;
// Implement this function
}
}
class FishTick extends TimerTask{
@Override
public void run() {
if (FishTank.mSimulateStatus){
for (int x=0;x<GlobalVariables.getInstance().mFish.size();x++){
Fish f = GlobalVariables.getInstance().mFish.get(x);
f.move();
GlobalVariables.getInstance().mFish.set(x, f);
}
GlobalVariables.getInstance().mFishTank.mDrawPanel.paint();
}
}
}
public class FishTank extends javax.swing.JFrame implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener{
private final int mNumRows = 20;
private final int mNumCols = 20;
private final int mGridSz = 30;
private int mSelectedFishIndex = -1;
private boolean mDragged = false;
private int mTopHeight;
JToolBar mToolbar;
JToggleButton mSimulationButton;
DrawPanel mDrawPanel;
private int mFishIndex = 0;
static public boolean mSimulateStatus = false;
public static void main(String[] args) {
GlobalVariables global = GlobalVariables.getInstance();
if (global == null){
System.out.println("Cannot initialize, exiting ....");
return;
}
}
private JToggleButton addButton(String title){
JToggleButton button = new JToggleButton(title);
button.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
mSimulateStatus = !mSimulateStatus;
}
});
this.mToolbar.add(button);
return (button);
}
public FishTank()
{
JFrame guiFrame = new JFrame();
guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
guiFrame.setTitle("MY FISH TANK");
// Create a toolbar and give it an etched border.
this.mToolbar = new JToolBar();
this.mToolbar.setBorder(new EtchedBorder());
mSimulationButton = addButton("Simulate");
this.mToolbar.add(mSimulationButton);
//This will center the JFrame in the middle of the screen
guiFrame.setLocationRelativeTo(null);
this.mDrawPanel = new DrawPanel(mNumRows, mNumCols, mGridSz);
this.mDrawPanel.setBackground(Color.cyan);
this.mDrawPanel.paint();
guiFrame.add(mDrawPanel);
guiFrame.add(this.mToolbar, BorderLayout.NORTH);
// Add the Exit Action
JButton button = new JButton("Quit");
button.setToolTipText("Quit the program");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
mToolbar.add(button);
guiFrame.addMouseListener(this);
guiFrame.addMouseMotionListener(this);
//make sure the JFrame is visible
guiFrame.setVisible(true);
mTopHeight = guiFrame.getInsets().top + mToolbar.getHeight();
guiFrame.setSize(mNumRows * mGridSz, mNumCols * mGridSz + mTopHeight);
Timer timer = new Timer("tick", true);
timer.scheduleAtFixedRate(new FishTick(), Calendar.getInstance().get(Calendar.MILLISECOND), 500);
}
@Override
public void mouseClicked(MouseEvent e) {
// Implement this function
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
// Implement this function
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseDragged(MouseEvent e) {
// Implement this function
}
@Override
public void mouseMoved(MouseEvent e) {
}
}
class DrawPanel extends JPanel{
int mRows;
int mCols;
int mGridSz;
int maxGridSz;
ArrayList<Fish> mFish;
public DrawPanel(int numberOfRows, int numberOfCols, int gridSz){
mGridSz = gridSz;
mRows = numberOfRows;
mCols = numberOfCols;
maxGridSz = mGridSz * mRows;
}
private void paintBackground(Graphics g){
for (int i = 1; i < mRows; i++) {
g.drawLine(i * mGridSz, 0, i * mGridSz, maxGridSz);
}
for (int mAnimateStatus = 1; mAnimateStatus < mCols; mAnimateStatus++) {
g.drawLine(0, mAnimateStatus * mGridSz, maxGridSz, mAnimateStatus * mGridSz);
}
}
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
paintBackground(g);
for (Fish f:GlobalVariables.getInstance().mFish){
f.paint(g);
}
}
public void paint(){
repaint();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.