-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f17819
commit 15cbd16
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
-r requirements.txt | ||
pytest==7.4.4 | ||
pytest-mock==3.12.0 | ||
datasets==2.16.1 | ||
pandas==2.1.4 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from datasets import load_dataset | ||
import pandas as pd | ||
import timeit | ||
import os | ||
|
||
dataset = load_dataset("inria-soda/tabular-benchmark", 'clf_cat_albert') | ||
|
||
df = pd.DataFrame(dataset['train']) | ||
|
||
file_formats = { | ||
'csv': { | ||
'write': lambda df: df.to_csv('sample.csv', index=False), | ||
'read': lambda: pd.read_csv('sample.csv') | ||
}, | ||
'json': { | ||
'write': lambda df: df.to_json('sample.json', orient='records'), | ||
'read': lambda: pd.read_json('sample.json') | ||
}, | ||
'parquet': { | ||
'write': lambda df: df.to_parquet('sample.parquet', index=False), | ||
'read': lambda: pd.read_parquet('sample.parquet') | ||
}, | ||
'orc': { | ||
'write': lambda df: df.to_orc('sample.orc', index=False), | ||
'read': lambda: pd.read_orc('sample.orc') | ||
} | ||
} | ||
|
||
for format, methods in file_formats.items(): | ||
print(f"Testing for {format.upper()} format:") | ||
|
||
write_time = timeit.timeit(lambda: methods['write'](df), number=10) | ||
read_time = timeit.timeit(methods['read'], number=10) | ||
|
||
write_file_size = os.path.getsize(f'sample.{format}') / (1024 * 1024) # Convert bytes to MB | ||
|
||
print(f"Average time taken to write: {write_time / 10:.6f} seconds") | ||
print(f"Average time taken to read: {read_time / 10:.6f} seconds") | ||
print(f"File size after write: {write_file_size:.6f} MB") | ||
print("\n") |