Giter Site home page Giter Site logo

adamrossnelson / stataquickreference Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 10.0 31.7 MB

A place to keep Stata code on quick reference.

License: MIT License

Stata 0.80% Jupyter Notebook 0.90% HTML 98.30%
stata graphics graphic-schemes beginner-friendly visualization visualize-data

stataquickreference's Issues

Data Is Beautiful Scheme

A good place to look for guidance on schemes:

https://www.stata.com/meeting/12uk/vw_README.txt
http://www.stata.com/meeting/12uk/schemetalk.zip

Simple red and black styles:

http://tylervigen.com/spurious-correlations

With dark backgrounds:

http://tylervigen.com/page?new=TRUE

Also helpful will be help scheme entries and:

https://www.stata.com/meeting/portugal10/portugal10_rising.pdf

Add 'loop over var names' Stata to Pandas crosswalk

Some example code...

>>> vars
['yr2000', 'yr2001', 'yr2002', 'yr2003', 'yr2004', 'yr2005', 'yr2006', 'yr2007', 'yr2008', 'yr2009', 'yr2010', 'yr2011', 'yr2012', 'yr2013', 'yr2014', 'yr2015', 'yr2016', 'yr2017', 'yr2018', 'yr2019']
>>>

Also

>>> for i in range(2013,2019):
...    df_dict[i] = pd.read_stata('list_of_caids_numsub_{}.dta'.format(i))
...
>>> df_dict[2014].columns
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')

>>> for i in range(2013, 2019):
...    df_dict[i].columns
...
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
Index(['ApplicantId', 'numSub', 'didSub', 'sessyr'], dtype='object')
>>> for i in range(2013, 2019):
...    df_dict[i].columns = [c if c == 'ApplicantId' else c + str(i) for c in df_dict[i].columns]
...
>>> for i in range(2013, 2019):
...    df_dict[i].columns
...
Index(['ApplicantId', 'numSub2013', 'didSub2013', 'sessyr2013'], dtype='object')
Index(['ApplicantId', 'numSub2014', 'didSub2014', 'sessyr2014'], dtype='object')
Index(['ApplicantId', 'numSub2015', 'didSub2015', 'sessyr2015'], dtype='object')
Index(['ApplicantId', 'numSub2016', 'didSub2016', 'sessyr2016'], dtype='object')
Index(['ApplicantId', 'numSub2017', 'didSub2017', 'sessyr2017'], dtype='object')
Index(['ApplicantId', 'numSub2018', 'didSub2018', 'sessyr2018'], dtype='object')
>>> df = df_dict[2013]
>>> for i in range(2014, 2019):
...    df = pd.merge(df, df_dict[i], how='outer')
...
>>> df.columns
Index(['ApplicantId', 'numSub2013', 'didSub2013', 'sessyr2013', 'numSub2014',
       'didSub2014', 'sessyr2014', 'numSub2015', 'didSub2015', 'sessyr2015',
       'numSub2016', 'didSub2016', 'sessyr2016', 'numSub2017', 'didSub2017',
       'sessyr2017', 'numSub2018', 'didSub2018', 'sessyr2018'],
      dtype='object')
>>>

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.