Skip to content

Instantly share code, notes, and snippets.

Aquabiota Solutions AB mapcloud

Block or report user

Report or block mapcloud

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile


:%norm A*


%       = for every line
norm    = type the following commands
A*      = Append `*` the end of current line
mapcloud /
Created Oct 9, 2017
pandas data frame rows into columns based by category. Kind of transposing the data.
# Source:
# convert the module variables into columns and group by the id. So something like:
# Example
ls = [{'count':5, 'module':'payroll', 'id':2}, {'count': 53, 'module': 'general','id':2}, {'id': 5,'count': 35, 'module': 'tax'}, ]
df = pd.DataFrame.from_dict(ls)
# Solution
# You can use groupby by columns which first create new index and last column. then need aggreagate some way - I use mean, then convert one column DataFrame to Series by DataFrame.squeeze (then is not necessary remove top level of Multiindex in columns) and reshape by unstack. Last add_suffix to column name
df = df.groupby(['id','module']).mean().squeeze().unstack().add_suffix('_count')
mapcloud /
Created Jul 28, 2017
Finding values which are empty strings with pandas and applymap
np.where(df.applymap(lambda x: x == ''))
mapcloud /
Created Jul 28, 2017
Pandas to GeoJSON (Multiples points + features) with Python
# Real source heroes here:
import json
import simplekml
import geojson
import pandas as pd
def data2kml(df):
kml = simplekml.Kml()
df.apply(lambda X: kml.newpoint(
mapcloud /
Created Jul 27, 2017 — forked from jeromer/
compass bearing between two points in Python
def calculate_initial_compass_bearing(pointA, pointB):
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
- `pointA: The tuple representing the latitude/longitude for the
mapcloud /
Last active Dec 18, 2017
How to Delete All <none>, Untagged and dangling Docker Containers and Images?

Transfer docker image to non-internet-connected machine

See Docker save docs

Create a backup that can then be used with docker load

$ docker save busybox > busybox.tar

$ ls -sh busybox.tar

2.7M busybox.tar
mapcloud / bash
Created Jul 10, 2017
How to split a very large text file into smaller files
View bash
awk '{outfile=sprintf("fileName%02d.tsv",NR/100000+1);print > outfile}' fileName_of_really_big_textfile.tsv
mapcloud /
Created Jun 8, 2017 — forked from lebedov/
Define and use custom step in Gremlin via pyorient.
#!/usr/bin/env python
Define and use custom step in Gremlin via pyorient.
from pyorient.ogm import Graph, Config
from pyorient.ogm.declarative import declarative_node, declarative_relationship
from import String
mapcloud /
Last active Apr 29, 2017
Python: Creates an unique list for a given list of dictionaries. Useful to remove duplicates of dictionaries within a list.
# Credits to:
import ast
def unique_list_in_list_of_dictionaries(content_list: list())->list:
content_list = [{'A':1, 'B':1, 'C':1},
{'A':1, 'B':1, 'C':1},
{'A':2, 'B':2, 'C':2}
{'A':3, 'B':2, 'C':1}
{'A':3, 'B':2, 'C':1}]
You can’t perform that action at this time.