A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
| """making a dataframe""" | |
| df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB')) | |
| """quick way to create an interesting data frame to try things out""" | |
| df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd']) | |
| """convert a dictionary into a DataFrame""" | |
| """make the keys into columns""" | |
| df = pd.DataFrame(dic, index=[0]) |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| __author__ = 'David Manouchehri' | |
| from bs4 import BeautifulSoup | |
| import urllib.request | |
| import gzip | |
| import io | |
| url = 'http://yoururlgoesherehopefullythisisntavalidurl.com/pages.html' | |
| headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', |
The slides for this code.
If you're trying to learn the basics of the Array methods, this thorough tutorial with answers is a great place to start.
Found some WONDERFUL documentation if you're curious what type of observable to use or method to use on your data. It shows it in a big table of user stories.
Lee Campbell has some examples as well.
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa | |
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa | |
| ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa |
| ##| patterns | |
| ##| environment | |
| use_bpm 480; | |
| use_random_seed 0; | |
| LOGGING = false; | |
| ##| domain | |
| BASE_NOTE = :c3; | |
| NUM_OCTAVES = 3; |
| # Store this in your ~/.bashrc file. Note that a .bashrc file is really just a regular shellscript, | |
| # but it must be executed _inside_ the current shell instead of as a subprocess in order for its | |
| # definitions to apply to the current shell. Alternatively, you can apply this file from within | |
| # your ~/.bashrc (or interactively in a shell) with `source /path/to/file.bashrc` | |
| # or `. /path/to/file.bashrc`. | |
| # Basic aliases that simply expand to the given command (which, in the case of git, | |
| # may involve git aliases). Note that you may append any parameters/flags when invoking the alias, |