This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List Comprehension / Map / Lambda Fucntions Explained SUPER EASY | |
| # say you have a list of files and want to work with the extensions. | |
| files = ['tony.txt', 'fraser.csv', 'ex.xls'] | |
| # it could be a function, you could loop through it. | |
| def get_suffix(file:str): | |
| return file.split('.')[1] | |
| # for file in files: print(get_suffix(file)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from numpy import randn | |
| rows = ['a','b','c','d','e'] | |
| cols = ['w','x','y','z'] | |
| df = pd.DataFrame(randn(5,4), rows, cols) | |
| # w x y z | |
| # a 2.706850 0.628133 0.907969 0.503826 | |
| # b 0.651118 -0.319318 -0.848077 0.605965 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this is for pip3 and pip3 ipython, you should ave these installed and be able to run. | |
| # thunder:~ user$ pip3 install seaborn ipython matplotlib | |
| ################### Using mathplotlib ################ | |
| # thunder:~ user$ ipython | |
| import seaborn as sns | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| # %matplotlib inline # <- don't do this, your terminal can't render this. You need the popups. | |
| titanic = pd.read_csv('https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # load random weblog data | |
| columns = ['accept_language', 'domain', 'geo_city', 'geo_country','post_mobiledevice', 'post_mobileosversion'] | |
| s3.load(full_path='{bucket}/tfraser/{weblog}/{folder}/', | |
| file_type='csv', | |
| file_filter=".csv" | |
| )[columns].dropna(how='any').copy() | |
| # data looks like this. | |
| # accept_language domain geo_city geo_country post_mobiledevice post_mobileosversion | |
| #0 en-us rr.com austin usa iPad4,2 iOS 11.1.2 |
NewerOlder