List-Files

Fri 14 November 2025

title: "List Files" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from os import listdir
from os.path import isfile, join
def list_files(mypath):
    onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]

    for x in onlyfiles:
        print(x)
list_files('/tmp/datasets')
credit.zip
occupancy.zip …

Category: file-utils

Read More

List-Operations

Fri 14 November 2025

title: "List Operations" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


list = [
    "AB", 
    "CD",
    "EF",
    "GH",
    "IJ", 
    "KL",
    "MN",
    "OP",
    "QR",
    "ST",
    "UV",
    "WX",
    "YZ"
]
list
['AB', 'CD', 'EF', 'GH', 'IJ', 'KL', 'MN', 'OP', 'QR', 'ST', 'UV', 'WX', 'YZ']
# append to list
list.append("ABC")
list
['AB',
 'CD',
 'EF …

Category: basics

Read More

List Ref

Fri 14 November 2025

title: "List Reference" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


a = [
    1, 2, 3, 4
]
b = a
b
[1, 2, 3, 4]
b.append(5)
a
[1, 2, 3, 4, 5]

As b is referring to a, whatever is added to b, will be reflected to …

Category: basics

Read More

List-Remove

Fri 14 November 2025

title: "Remove Item from list" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


names = [
    "Kevin",
    "Peter",
    "John"
]
names
['Kevin', 'Peter', 'John']
names.pop(0)
'Kevin'
names
['Peter', 'John']


Score: 5

Category: basics

Read More

List Test

Fri 14 November 2025

title: "List Test" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


entries = ['one', 2, 'three', False]
print(entries)
['one', 2, 'three', False]
print(entries[2:7])
['three', False]
entryTuple = (100, 200, 'three', 'four')
print(entryTuple)
(100, 200, 'three', 'four')
cities = ['Toronto', 'Monteal', 'Vancouver']
print(cities)
['Toronto', 'Monteal …

Category: basics

Read More

List Test 2

Fri 14 November 2025

title: "List Test 2" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


entries = ['one', 2, 'three', False]
print(entries)
['one', 2, 'three', False]
print(entries[2:7])
['three', False]
entryTuple = (100, 200, 'three', 'four')
print(entryTuple)
(100, 200, 'three', 'four')
cities = ['Toronto', 'Monteal', 'Vancouver']
print(cities)
['Toronto …

Category: basics

Read More

List-With-Diff-Datatype

Fri 14 November 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==1.0.1

lista = ["one", 2, "three …

Category: basics

Read More

List2Table

Fri 14 November 2025

import pandas as pd
from IPython.display import display

# Example list of tuples
data = [
    (1, 'Alice', 25),
    (2, 'Bob', 30),
    (3, 'Charlie', 35)
]

# Convert the list of tuples to a DataFrame
df = pd.DataFrame(data, columns=['ID', 'Name', 'Age'])

# Set display options
pd.set_option('display.max_rows', 100)
pd.set_option('display …

Category: pandas

Read More

List2Table-D-Pandas

Fri 14 November 2025

import pandas as pd
from IPython.display import display

# Example list of tuples
data = [
    (1, 'Alice', 25),
    (2, 'Bob', 30),
    (3, 'Charlie', 35)
]

# Convert the list of tuples to a DataFrame
df = pd.DataFrame(data, columns=['ID', 'Name', 'Age'])

# Set display options
pd.set_option('display.max_rows', 100)
pd.set_option('display …

Category: duckdb

Read More

Loc With Boolean

Fri 14 November 2025

title: "If Else Pandas" author: "Rj" date: 2019-04-24 description: "-" type: technical_note draft: false source: http://pandas.pydata.org/pandas-docs/version/0.24/user_guide/cookbook.html#idioms


import numpy as np
import pandas as pd
df = pd.DataFrame({
    'maths' : [80, 89, 90, 20],
    'science' : [40, 50, 90, 100],
    'language' : [20, 30 …

Category: data-wrangling

Read More
Page 113 of 146

« Prev Next »