Skip to main content

Customer purchases large dataset processing pipeline

Project description

# Basic chunked reading
import pandas as pd

chunksize = 100_000
reader = pd.read_csv('huge_orders.csv', chunksize=chunksize)
for chunk in reader:
    print(f"Chunk shape: {chunk.shape}")

# feltered_chunks = []
total_sales = 0
for chunk in pd.read_csv('huge_orders.csv', chunksize=100_000):
    chunk['total'] = chunk['quantity'] * chunk['price']
    total_sales += chunk['total'].sum()
print(total_sales)

# Filter and save to file
filtered_chunks = []
for chunk in pd.read_csv('huge_orders.csv', chunksize=100_000):
    filtered = chunk[chunk['country'] == 'USA']
    filtered_chunks.append(filtered)
## Combine and save
pd.concat(filtered_chunks)to_csv('usa_orders.csv', index=False)


# Unique value counting across chunks
uni_customers = set()
for chunk in pd.read_csv('huge_orders.csv', chunksize=100_000):
    unique_customers.update(chunk['customer_id'].unique())
print(len(unique_custormers))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

customer_purchases_final-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

customer_purchases_final-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file customer_purchases_final-1.0.0.tar.gz.

File metadata

  • Download URL: customer_purchases_final-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.14.0-27-generic

File hashes

Hashes for customer_purchases_final-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ac55ffe344b090ffe3b6be297fa3539a03ed45837bb199056f8babfda644c73f
MD5 ba5a20c6b83e64b3dafcedd086108bc2
BLAKE2b-256 b5730032fa1e4e3081e2064b2d44f13665a293bdd5e3c9ee8934f71ec1c80e43

See more details on using hashes here.

File details

Details for the file customer_purchases_final-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for customer_purchases_final-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b67de8d188e233a70bd55a58f41b2f20b4b89a067b63cc61cc6db34d204c51b
MD5 7451d8493a4b140e5bdf1045ccbf5a02
BLAKE2b-256 cc03a8890b917aa2346434e97b9fb0de7e7047ba2220217abbda849b2584f8a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page