Skip to content

Commit d21e3ea

Browse files
drewaoglebovlbCopilot
authored
Small fixes to CSV df and Configuration token (#599)
* add check for supplied df in CSVParser * supply token to created Configuration from config file * fix comment * formatting * account for dask in df check. * Apply suggestions from code review Co-authored-by: bovlb <[email protected]> Co-authored-by: Copilot <[email protected]> * fix formatting --------- Co-authored-by: bovlb <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 825c234 commit d21e3ea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

aperturedb/CSVParser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ def __init__(self,
6262
self.df = pd.read_csv(filename)
6363
else:
6464
self.df = df
65+
66+
# we expect the df index to have 'start', which means RangeIndex.
67+
# most users don't supply their own df, so this is mostly a sanity check
68+
# for when an advanced user has done filtering and have a IntervalIndex.
69+
if not isinstance(self.df.index, pd.RangeIndex):
70+
raise TypeError(
71+
f"CSVParser requires a RangeIndex. the supplied DataFrame has a {type(self.df.index)} index.")
6572
else:
73+
if df is not None:
74+
raise ValueError(
75+
"Dask mode requires a CSV filename; DataFrame inputs are not supported.")
6676
# It'll impact the number of partitions, and memory usage.
6777
# TODO: tune this for the best performance.
6878
cores_used = int(CORES_USED_FOR_PARALLELIZATION * mp.cpu_count())

0 commit comments

Comments
 (0)