Dict-With-Indent
import json
# Example dictionary
result_dict = {
"name": "John Doe",
"age": 30,
"location": {
"city": "New York",
"country": "USA"
}
}
# Convert dictionary to JSON string with indentation
formatted_json = json.dumps(result_dict, indent=4)
# Print the formatted JSON
print(formatted_json)
{
"name": "John Doe",
"age": 30,
"location": {
"city": "New York",
"country": "USA"
}
}
from IPython.display import …
Read More
Dispersion-Plot-On-Custom-File
title: "Disperson Plot on Custom File"
author: "Rj"
date: 2019-04-21
description: "-"
type: technical_note
draft: false
f =open('canola.txt','r')
raw = f.read()
'OTTAWA—The federal Liberals promised Wednesday to give Canada’s canola farmers much-needed financial aid to help lessen the impact of China’s decision …
Read More
Disperson-Plot
title: "Disperson Plot"
author: "Rj"
date: 2019-04-21
description: "-"
type: technical_note
draft: false
from nltk.book import text3
<Text: The Book of Genesis>
content = ''
counter = 10
for token in text3.tokens:
counter += 1
content += token + ' '
if(counter > 200):
break
content
Read More
Dns-Lookup
title: "DNS Lookup"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
addr1 = socket.gethostbyname('google.com')
addr2 = socket.gethostbyname('yahoo.com')
Score: 5
Read More
Domain-Finder
title: "Find Domain"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
def get_domain(url):
spltAr = url.split("://")
i = (0,1)[len(spltAr)>1]
dm = spltAr[i].split("?")[0].split('/')[0].split(':')[0].lower()
#print(dm)
return dm
def get_domain_without_prefix(url):
spltAr = url.split("://")
i = (0,1)[len …
Read More
Donut-Plot
title: "Donut Plot"
author: "Rj"
date: 2020-08-20
description: "Donut Plot"
type: technical_note
draft: false
Source:
https://matplotlib.org/3.1.1/gallery/pie_and_polar_charts/nested_pie.html
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
size = 0.3
vals = np.array([[60, 32], [37, 40]])
cmap = plt …
Read More
Donut-Plot-With-Subgroups
title: "Donut Plot with subgroups"
author: "Rj"
date: 2020-08-20
description: "Donut Plot"
type: technical_note
draft: false
Source:
https://python-graph-gallery.com/163-donut-plot-with-subgroups/
# Libraries
import matplotlib.pyplot as plt
# Make data: I have 3 groups and 7 subgroups
group_names=['groupA', 'groupB', 'groupC']
group_size=[12,11,30]
subgroup_names=['A.1', 'A.2', 'A …
Read More
Double-Pendulum
from bokeh.plotting import figure, output_file, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource
# Set Bokeh output to notebook
output_notebook()
Read More
Download
import os
import pandas as pd
from kaggle.api.kaggle_api_extended import KaggleApi
from io import BytesIO
import zipfile
# Authenticate with Kaggle
api = KaggleApi()
api.authenticate()
!kaggle datasets files zillow/zecon
name size creationDate
---------------------------- ----- -------------------
City_time_series.csv 658MB 2019-09-21 10:26:35
CountyCrossWalk_Zillow.csv 227KB 2019-09-21 10:26:18
County_time_series.csv 108MB …
Read More
Download-2
import kagglehub
# Download latest version
path = kagglehub.dataset_download("harlfoxem/housesalesprediction")
print("Path to dataset files:", path)
/home/rajaraman/miniconda3/envs/ml312/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install …
Read More