Generator-Sample-1

Fri 14 November 2025

# Example: Loop through a generator and print its values
def sample_generator():
    for i in range(5):  # Generates numbers 0 to 4
        yield i
gen = sample_generator()  # Create the generator
gen
<generator object sample_generator at 0x7fe180371000>
for value in gen:  # Loop through the generator
    print(value)
0
1
2
3
4


Score …

Category: basics

Read More

Genertor-On-Stream

Fri 14 November 2025
from constants import OPENAI_API_KEY
!pip show langchain-openai | grep "Version:"
Version: 0.2.9
import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o-mini")
from langchain_core.output_parsers import JsonOutputParser


async def _extract_country_names_streaming(input_stream):
    """A function that operates on input streams."""
    country_names_so_far = set()

    async for input in …

Category: langchain

Read More

Gensim-Similarity

Fri 14 November 2025

title: "Gensim Similarity" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


import nltk 
import gensim
sample="""Renewed fighting has broken out in South Sudan between forces loyal to the president and vice-president. A reporter in the capital, Juba, told the BBC gunfire and large explosions could be heard all …

Category: textprocessing

Read More

Geo Distance

Fri 14 November 2025

title: "Geo Distance" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="rajarcsp")
from geopy import distance
l_spadina = geolocator.geocode("28 Spadina Road")
l_spadina_latlong = l_spadina.latitude, l_spadina.longitude
l_spadina_latlong
(43.6966329769175, -79.7940236288173)
l_north_york = geolocator.geocode("5000 Yonge Street")
l_north_york_latlong …

Category: geopandas

Read More

Geo Distance Method

Fri 14 November 2025

title: "Geo Distance Method" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="rajarcsp")
from geopy import distance
def get_distance(one, two):
    cone = geolocator.geocode(one)
    ctwo = geolocator.geocode(two)

    one_latlong = cone.latitude, ctwo.longitude
    two_latlong = ctwo.latitude, ctwo.longitude …

Category: geopandas

Read More

Geo Location 1

Fri 14 November 2025

title: "Geo Location 1" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import requests
import json 
send_url = 'http://api.ipstack.com/50.100.30.136?access_key=49ad529d309a09477749245782d260b8&format=1'
r = requests.get(send_url)
j = json.loads(r.text)

lat = j['latitude']
lon = j['longitude']
print(lat)
print(lon)
43 …

Category: basics

Read More

Geo Location 2

Fri 14 November 2025

title: "Geo Location by Geocoder" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import geocoder
g = geocoder.ip('me')
print(g.latlng)
[43.6909, -79.3098]
test_location = geocoder.ip('151.101.1.69')
print(test_location.latlng)
[37.751, -97.822]


Score: 5

Category: basics

Read More

Geopandas Canada

Fri 14 November 2025

title: "Geo Pandas Canada" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import pandas as pd
import geopandas
import matplotlib.pyplot as plt
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="rajarcsp")
def get_lat_lang(city):
    location = geolocator.geocode(city)
    return location.latitude, location.longitude
to_lat, to_long = get_lat_lang …

Category: geopandas

Read More

Geopandas Simple

Fri 14 November 2025

title: "Geo Pandas Simple" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import pandas as pd
import geopandas
import matplotlib.pyplot as plt
df = pd.DataFrame(
    {'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas'],
     'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela'],
     'Latitude': [-34.58, -15.78, -33.45, 4 …

Category: geopandas

Read More

Geopy Simple

Fri 14 November 2025

title: "Template" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="rajarcsp")
location = geolocator.geocode("175 5th Avenue NYC")
location
Location(Flatiron Building, 175, 5th Avenue, Flatiron District, Manhattan, Manhattan Community Board 5, New York County, NYC, New York, 10010 …

Category: geopandas

Read More
Page 105 of 146

« Prev Next »