Coder Social home page Coder Social logo

ds-skills-correlation-iteration-atlanta-ds-100918's Introduction

import pandas as pd
df = pd.read_csv('causes_of_death.tsv', delimiter='\t')
print(len(df))
df.head()
4115
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
Notes State State Code Ten-Year Age Groups Ten-Year Age Groups Code Gender Gender Code Race Race Code Deaths Population Crude Rate
0 NaN Alabama 1 < 1 year 1 Female F American Indian or Alaska Native 1002-5 14 3579 Unreliable
1 NaN Alabama 1 < 1 year 1 Female F Asian or Pacific Islander A-PI 24 7443 322.5
2 NaN Alabama 1 < 1 year 1 Female F Black or African American 2054-5 2093 169339 1236.0
3 NaN Alabama 1 < 1 year 1 Female F White 2106-3 2144 347921 616.2
4 NaN Alabama 1 < 1 year 1 Male M Asian or Pacific Islander A-PI 33 7366 448.0

Practice Explorations

Groupby State and Sum the numeric features.

# Groupby State
grouped = #Your code here 

Calculate the Correlation Coefficient between the Deaths and Population Columns (of your grouped dataframe)

#Your code here

Repeat this process across multiple features

Iterate over the following columns: ['Race', 'Gender', 'Ten-Year Age Groups']. Within your for loop, create a temporary groupby aggregate as we did for the State column above. Then, print any aggregate grouping where the correlation coefficient is less then .95.

#Your code here

Combining Features

We can further expand upon our exploration above by testing multiple features against each other! Complete the code below to print any combination of features where the correlation between population and death is below .95 (or some other appropriate threshold).

#This could also be accomplished with the combinations() method from the itertools package.
for n, feat1 in enumerate(features):
    for feat2 in features[n:]:
        #Your code here
        #groupby feat1 and feat2!!
        #repeat your code above to check if the correlation is below a [high] threshold.

ds-skills-correlation-iteration-atlanta-ds-100918's People

Contributors

mathymitchell avatar

Watchers

 avatar James Cloos avatar Kevin McAlear avatar  avatar Victoria Thevenot avatar Belinda Black avatar  avatar Joe Cardarelli avatar Sam Birk avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Jaichitra (JC) Balakrishnan avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar A. Perez avatar Nicole Kroese  avatar  avatar Lore Dirick avatar Nicolas Marcora avatar Lisa Jiang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.