Dict-With-Indent

Fri 14 November 2025
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 …

Category: langchain

Read More

Dispersion-Plot-On-Custom-File

Fri 14 November 2025

title: "Disperson Plot on Custom File" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


import nltk
f =open('canola.txt','r')
raw = f.read()
raw
'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 …

Category: textprocessing

Read More

Disperson-Plot

Fri 14 November 2025

title: "Disperson Plot" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


from nltk.book import text3
text3
<Text: The Book of Genesis>
type(text3)
nltk.text.Text
len(text3)
44764
content = ''
counter = 10
for token in text3.tokens:
    counter += 1
    content += token + ' '

    if(counter > 200):
        break

content
'In the …

Category: textprocessing

Read More

Dns-Lookup

Fri 14 November 2025

title: "DNS Lookup" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import socket
addr1 = socket.gethostbyname('google.com')
addr2 = socket.gethostbyname('yahoo.com')
print(addr1)
172.217.0.238
print(addr2)
98.137.246.8


Score: 5

Category: basics

Read More

Domain-Finder

Fri 14 November 2025

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 …

Category: basics

Read More

Donut-Plot

Fri 14 November 2025

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 …

Category: plot

Read More

Donut-Plot-With-Subgroups

Fri 14 November 2025

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 …

Category: plot

Read More

Double-Pendulum

Fri 14 November 2025

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()

Category: bokeh

Read More

Download

Fri 14 November 2025
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 …

Category: kaggle

Read More

Download-2

Fri 14 November 2025

# !pip install kagglehub
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 …

Category: kaggle

Read More
Page 98 of 146

« Prev Next »