Skip to main content

Customer purchases large dataset

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-1.0.0.tar.gz (2.8 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-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: customer_purchases-1.0.0.tar.gz
  • Upload date:
  • Size: 2.8 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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d81d38e1f299c76613c01c94d167ecd704ca9e4ecfa0bd3d068cb91585bab658
MD5 2c4d1cf73432418c58c588326206bb04
BLAKE2b-256 4963e443e61f4ebce4ee06bcb46e1f4e41fab0828ec7ab659d3227ca10e35492

See more details on using hashes here.

File details

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

File metadata

  • Download URL: customer_purchases-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • 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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13d4f95fe07610942484a73cb13df2f10aa9d24e55bb0f1e7cbd3a31ddea5baa
MD5 6f695c1655eba7517f1a6a6f7c3247d4
BLAKE2b-256 503559d40dc998d524ef9d65570721423d3236a65d512a9d9e9c5a37d40f0ee1

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