Skip to content

Instantly share code, notes, and snippets.

@Ayeeta
Ayeeta / MoreVairables.kt
Created August 1, 2020 20:09
more on variables
//Explicitly declared
var someVariableName: String = "Explicitly declared variable of type String"
val someIntValue: Int = 343
val someDoubleValue: Double = 343.24
//Implicitly declared
var someVariableName = "Implicitly declared variable of type String"
val someIntValue = 343
@Ayeeta
Ayeeta / immutable.kt
Created August 1, 2020 19:50
immutable variables
val someVariableName = "Kotin is fun and you can't re-assign me!"
@Ayeeta
Ayeeta / mutable.kt
Created August 1, 2020 19:41
Mutable Variables
var someVariableName = "Kotlin is fun!"
@Ayeeta
Ayeeta / plot.py
Created September 25, 2019 21:09
plot coordinates on a map
fig = plt.figure(figsize = (12,9))
m = Basemap(projection='mill',
llcrnrlat = -90,
urcrnrlat = 90,
llcrnrlon = -180,
urcrnrlon = 180,
resolution = 'c')
lon_x = users_dataFrame['Longitude'].tolist()
lat_y = users_dataFrame['Latitude'].tolist()
@Ayeeta
Ayeeta / exploratory.py
Created September 25, 2019 21:07
exploratory analysis
users_dataFrame = pd.read_csv('users.csv')
users_dataFrame
@Ayeeta
Ayeeta / load.py
Created September 25, 2019 21:00
load users_table data to csv
tocsv(users_table, 'users.csv')
@Ayeeta
Ayeeta / transform.py
Created September 25, 2019 20:54
Transform users_table
users_table = unpackdict(users_table, 'address')
users_table = unpackdict(users_table, 'geo')
#select a few columns
users_table = cut(users_table, 'id', 'name','username','email','phone','city','street','suite','lat','lng')
#rename column headers
users_table = rename(users_table, {'name':'Name','username':'Username','email':'Email','phone':'Phone','city':'City','street':'Street','suite':'Suite','lat':'Latitude', 'lng':'Longitude'})
users_table
@Ayeeta
Ayeeta / extract.py
Created September 25, 2019 20:28
extract from API
#Extract
users_table = fromdicts(data)
users_table
@Ayeeta
Ayeeta / loadAPI.py
Created September 25, 2019 20:21
load data from API end point
jsonurl = urllib.request.urlopen("https://jsonplaceholder.typicode.com/users")
data = json.loads(jsonurl.read())
data
from petl import look, fromdb,fromjson,fromdicts,unpackdict,cut, todb, rename, tocsv
from matplotlib.pyplot import figure
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from pandas import DataFrame
from plotly.subplots import make_subplots
from shapely.geometry import Point
from geopandas import GeoDataFrame
from mpl_toolkits.basemap import Basemap
import pandas as pd