language:en license:apache-2.0 size_categories:n<1K region:us
---
license: apache-2.0
language:
- en
size_categories:
- n<1K
---
import pandas as pd
import random
from faker import Faker

# Initialize Faker for generating random names and dates
fake = Faker()

# Generate data for 1000 transactions
num_records = 1000
data = []

# Define possible values for certain fields
transaction_types = ['Sale', 'Expense', 'Refund']
currencies = ['USD', 'EUR', 'GBP', 'CAD']

from datetime import datetime

# Fix date parsing issue by using datetime objects directly
start_date = datetime(2023, 1, 1)
end_date = datetime(2024, 9, 30)

# Generate data for 1000 transactions
data = []

# Generate dummy data with corrected date format
for _ in range(num_records):
    transaction_id = fake.unique.bothify(text='T####')
    customer_id = fake.random_number(digits=5, fix_len=True)
    customer_name = fake.name()
    transaction_date = fake.date_between_dates(date_start=start_date, date_end=end_date)
    amount = round(random.uniform(100, 2000), 2)
    revenue = round(random.uniform(0, amount), 2)
    expenses = round(random.uniform(0, amount - revenue), 2)
    profit = round(revenue - expenses, 2)
    transaction_type = random.choice(transaction_types)
    currency = random.choice(currencies)
    account_id = fake.bothify(text='ACC###')

    data.append([transaction_id, customer_id, customer_name, transaction_date, amount, revenue, expenses, profit, transaction_type, currency, account_id])

# Create DataFrame
columns = ['Transaction ID', 'Customer ID', 'Customer Name', 'Transaction Date', 'Amount', 'Revenue', 'Expenses', 'Profit', 'Transaction Type', 'Currency', 'Account ID']
df = pd.DataFrame(data, columns=columns)

# Create DataFrame
df = pd.DataFrame(data, columns=columns)

# Show the first few rows of the generated dataset
df.head()

# Save DataFrame to a CSV file
df.to_csv('transactions_dataset.csv', index=False)