Skip to content

Instantly share code, notes, and snippets.

View anil-kk's full-sized avatar

Anil Kumar Kothapalli anil-kk

View GitHub Profile
conda create -n tensorflow
conda activate tensorflow
pip install --ignore-installed --upgrade tensorflow
pip install jupyter notebook
pip install pandas
@anil-kk
anil-kk / gist:44288a6d02e297250a39808744a173cf
Created April 16, 2020 09:57
Rename git commits author details to a repo
git clone --bare https://github.com/user/repo.git
cd repo.git
_____________________________
copy the below commmands to help.sh file and make it executable by running this command
chmod +x help.sh
./help.sh
________________________________________________________________________
#!/bin/sh
@anil-kk
anil-kk / region_lookup.py
Last active November 3, 2020 15:00
Create lookup<region_code,name> for regions in Sweden from SCB data
import pandas as pd
import requests
import json
session = requests.Session()
res = session.get("http://api.scb.se/OV0104/v1/doris/sv/ssd/START/BE/BE0101/BE0101A/BefolkningNy")
region_variables = json.loads(res.content.decode('utf-8-sig'))['variables']
@anil-kk
anil-kk / scb_deso.py
Created November 5, 2020 09:04
SCB data DeSO
from pyscbwrapper import SCB
import pandas as pd
import re
import requests
import json
session = requests.Session()
###########################Region#############################
@anil-kk
anil-kk / DeSO_Lat_Lon_map.py
Created November 5, 2020 09:07
Map DeSO with Lat,Lon of Area of Interest
import pandas as pd
import geopandas
from shapely.geometry import Point
from shapely.geometry.polygon import Polygon
#https://www.scb.se/vara-tjanster/oppna-data/oppna-geodata/deso--demografiska-statistikomraden/
#https://www.scb.se/contentassets/923c3627a8a042a5b9215e8ff3bde0a3/deso_2018_v2.zip
countries_gdf = geopandas.read_file("DeSO_2018_v2.gpkg")
@anil-kk
anil-kk / barh.py
Created November 22, 2020 20:29
Horizontal bar with label for each bar
import pandas as pd
import numpy as np
# %matplotlib inline
import matplotlib.pyplot as plt
import matplotlib as mpl
#'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DV0101EN/labs/Data_Files/Canada.xlsx'
df = pd.read_excel('https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DV0101EN/labs/Data_Files/Canada.xlsx',
sheet_name='Canada by Citizenship',
skiprows=range(20),
@anil-kk
anil-kk / commands.md
Last active September 11, 2023 20:54
Create new conda environment and add the kernel to JupyterServer

Create new conda environment and add the kernel to existing jupyterlab

  • conda create -n my_env python=3.10
  • conda activate my_env
  • conda install jupyter
  • which python (should point to the one from new environment)
  • python -m ipykernel install --user --name="my_env" --display-name="my_env (Python 3.10)"
  • jupyter kernelspec list
  • !python3 -m jupyter kernelspec list (from notebook cell)

installing new module from terminal

@anil-kk
anil-kk / example.py
Created September 21, 2023 17:45
pandas groupby apply multiple aggregation functions on dataframe columns
import pandas as pd
import numpy as np
# Create a sample DataFrame
data = {'category': ['A', 'A', 'B', 'B', 'A', 'B'],
'value': [10, 20, 15, 25, 30, 35]}
df = pd.DataFrame(data)
# Group by 'category' and apply multiple aggregation functions
agg_functions = {