Skip to content

Instantly share code, notes, and snippets.

@lenamax2355
lenamax2355 / pyspark-melt.py
Created June 2, 2022 08:48 — forked from sllynn/pyspark-melt.py
melt a pyspark dataframe
from pyspark.sql.functions import array, col, explode, lit, struct
from pyspark.sql import DataFrame
from typing import Iterable
def melt(
df: DataFrame,
id_vars: Iterable[str], value_vars: Iterable[str],
var_name: str="variable", value_name: str="value") -> DataFrame:
"""Convert :class:`DataFrame` from wide to long format."""
@lenamax2355
lenamax2355 / custom.css
Created February 19, 2022 13:09 — forked from formigone/custom.css
Custom CSS for Jupyter Notebook web application
#notebook-container{
box-shadow: none !important;
}
.container {
width: 80% !important;
}
.notebook_app {
background: #fff !important;
@lenamax2355
lenamax2355 / sc_pandas_profiling.py
Created February 2, 2022 10:50 — forked from geodra/sc_pandas_profiling.py
pandas_profiling
def describe_numeric_1d(series: pd.Series, series_description: dict) -> dict:
"""Describe a numeric series.
Args:
series: The Series to describe.
series_description: The dict containing the series description so far.
Returns:
A dict containing calculated series description values.
Notes:
When 'bins_type' is set to 'bayesian_blocks', astropy.stats.bayesian_blocks is used to determine the number of
bins. Read the docs:
@lenamax2355
lenamax2355 / pythonista_supabase.py
Created January 22, 2022 16:07 — forked from jitsejan/pythonista_supabase.py
Pythonista script to read from Safari and write to Supabase
import appex
import json
import requests
LANGUAGE = "en-gb"
OXFORD_ID = "9acc1234"
OXFORD_KEY = "6baccf388cd6456456326e85054f30aba"
OXFORD_URL = "https://od-api.oxforddictionaries.com/api/v2"
OXFORD_HEADERS = {
"app_id": OXFORD_ID,
@lenamax2355
lenamax2355 / table2tree.ipynb
Created January 14, 2022 14:19 — forked from psychemedia/table2tree.ipynb
Convert a pandas dataframe describing a hierarchy to a JSON tree
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lenamax2355
lenamax2355 / DateDifference.py
Created January 4, 2022 19:02 — forked from amalgjose/DateDifference.py
This is a very simple python code snippet for calculating the difference between two dates or timestamps. This will calculate the difference in terms of number of years, months, days, hours, minutes etc. For more details, refer https://amalgjose.com/2015/02/19/python-code-for-calculating-the-difference-between-two-time-stamps/
__author__ = 'Amal G Jose'
from datetime import datetime
from dateutil import relativedelta
##Aug 7 1989 8:10 pm
date_1 = datetime(1989, 8, 7, 20, 10)
##Dec 5 1990 5:20 am
date_2 = datetime(1990, 12, 5, 5, 20)
// Highcharts CheatSheet Part 1.
// Create interactive charts easily for your web projects.
// Download: http://www.highcharts.com/download
// More: http://api.highcharts.com/highcharts
// 1. Installation.
// Highcharts requires two files to run, highcharts.js and either jQuery, MooTools or Prototype or the Highcharts Standalone Framework which are used for some common JavaScript tasks.
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
// <script src="https://code.highcharts.com/highcharts.js"></script>
@lenamax2355
lenamax2355 / find_place.py
Created December 18, 2021 13:20 — forked from jainsourabh/find_place.py
Finding places in Google API
# client object
client = googlemaps.Client(key = "YOUR API")
# most avaialable parameters
all_fields = ['business_status', 'formatted_address','geometry/location','name',
'place_id', 'rating','types', 'user_ratings_total','formatted_phone_number']
# desirable parameters
fields = ['place_id', 'name', 'formatted_address']
@curiousest
curiousest / compare_pandas_dataframes.py
Created November 25, 2021 17:12
Compare pandas dataframes
# Because I couldn't get this to do what I wanted:
# https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.compare.html
import pandas as pd
from typing import Optional, List
def compare_dataframes(df1, df2, drop_indexes=False, ignore_columns: Optional[List]=None):
'''Returns two dataframes: the rows that only show up in each dataframe'''
if drop_indexes:
df1 = df1.reset_index(drop=True)
@MarcSkovMadsen
MarcSkovMadsen / HvplotInteractive.ipynb
Created November 1, 2021 19:42
HvplotInteractive.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.