Skip to content

Instantly share code, notes, and snippets.

@luisdelatorre012
Last active August 8, 2024 12:45
Show Gist options
  • Save luisdelatorre012/7154adbf20a19fdc7fd9d80b2b9b6a7c to your computer and use it in GitHub Desktop.
Save luisdelatorre012/7154adbf20a19fdc7fd9d80b2b9b6a7c to your computer and use it in GitHub Desktop.
fake customer data
import polars as pl
from faker import Faker
import random
# Initialize the Faker instance
fake = Faker()
# Define the number of unique customers and the total number of records
num_customers = 100
num_records = 1000
# Generate unique customer names
customer_names = [fake.name() for _ in range(num_customers)]
# Generate the fake data
data = {
'shipment_id': [fake.uuid4() for _ in range(num_records)],
'customer_id': [random.choice(customer_names) for _ in range(num_records)],
'shipment_created_date_time': [fake.date_time_between(start_date='-2y', end_date='now') for _ in range(num_records)]
}
# Create a Polars DataFrame
df = pl.DataFrame(data)
# Display the first few rows of the DataFrame
print(df.head())
# Optionally, save the DataFrame to a CSV file
df.write_csv('fake_shipments.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment