I have an issue with the part of code which seems to work slowly.
I suppose it's because of iterating through a dataframe. Here is the code:
# creating a dataframe for ALL data
df_all = pd.DataFrame()
for idx, x in enumerate(all_data[0]):
peak_indx_E = ...
...
# TODO: speed up!
# it works slow because of this? How to avoid this problem if I need to output a dataframe
temp = pd.DataFrame(
{
'idx_global_num': idx,
...
'peak_sq_divE': peak_sq_divE
}, index=[idx]
)
df_all = pd.concat([df_all, temp])
Can you give me a suggestion - how can I speed up the execution - I suppose the pd.concat operation is slow.
How to solve this issue?