Repository navigation
How to run for loop faster ? #64
Unanswered
seanchang015181
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I write this sample code to import stdf file into pandas dataframe.
Is there's any better way to insert into pandas ?
(for REC in filtered_load_stdf need to run about 8 min !)
load stdf
load_stdf = STDF.records_from_file("xxx.std")
type(load_stdf)
filtered_load_stdf = filter(lambda rec: 'PRR' in str(rec), load_stdf)
type(filtered_load_stdf)
ttl_cnt = 9000
create PRR list
tmp_lst = []
with tqdm(total=ttl_cnt) as pbar:
for REC in filtered_load_stdf:
pbar.update(1)
stdf_dict = REC.to_dict()
tmp_lst.append(stdf_dict)
pandas dataframe - original format
df_original = pd.DataFrame.from_dict(tmp_lst)
df_original.head(3)
All reactions