Jul-25-2020, 02:09 AM
Hi,
I have blow list, I can reshape it but I want to reshape based on other condition:
#%%
if I have a list like:
I have blow list, I can reshape it but I want to reshape based on other condition:
#%%
import pandas as pd import numpy as np lst = ['A','',3,'A','',0,'A',3,2] aa = np.reshape(lst,(-1,3)) aa = pd.DataFrame(aa, columns=['A','B','C'])but I want to break the sub-list at each 'A'
A B C A 3 A 0 A 3 2I want to break at 'A' because some time columns may change,
if I have a list like:
lst = ['A','',3,'4','A','',0,'2020/07/25 10:13:23','A',3,2,''2020/07/25 10:13:29']in this case, i need to change np.reshape(lst,(-1,4)), which I want to avoide