Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stuff to add #1

Open
bodacea opened this issue Sep 29, 2019 · 0 comments
Open

stuff to add #1

bodacea opened this issue Sep 29, 2019 · 0 comments

Comments

@bodacea
Copy link
Owner

bodacea commented Sep 29, 2019

Change Jupyter display defaults:
pd.set_option('display.max_columns', 1000)

Reload a library in Python3.4 onwards:

import importlib
solveutils = importlib.reload(solveutils)

#importing from a different directory
import sys
sys.path.insert(0, "../libraries")
import solveutils

Drop all the duplicate rows (as in all copies of duplicates, including the originals) from a data frame: df[~df.duplicated(keep=False)]

Get the type of a column: dftweet['user'].apply(type)

#dump json to an output file
import json
with open('rawdata.json', 'w') as fout:
json.dump(rawdata, fout, ensure_ascii=False)

Sometimes you have to ask nicely for data (in this case, not adding headers got me a 403 error)

myheaders = {
'User-Agent': 'SJtest/1.0; +https://example.com',
'Accept': 'text/plain',
}
r = requests.get('https://100percentfedup.com/ads.txt',
headers=myheaders)
r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant