So, I am iterating through a dictionary and taking a bunch of values out as a array - Trying to make a Dataframe with each observation as a separate row.
X1 =[]
for k,v in DF_grp:
date = v['Date'].astype(datetime)
usage = v['Usage'].astype(float)
comm = v['comm'].astype(float)
mdf = pd.DataFrame({'Id' : k[0],'date':date,'usage':usage, 'comm':comm})
mdf['used_ratio'] = ((mdf['used']/mdf['comm']).round(2))*100
ts = pd.Series(mdf['usage'].values, index=mdf['date']).sort_index(ascending=True)
ts2 = pd.Series(mdf['used_ratio'].values, index = mdf['date']).sort_index(ascending=True)
ts2 = ts2.dropna()
data = ts2.values.copy()
if len(data) == 10:
X1 =np.append(X1,data, axis=0)
print(X1)
[0,0,0,0,1,0,0,0,1]
[1,2,3,4,5,6,7,8,9]
[0,5,6,7,8,9,1,2,3]
....
similarly, so the question is how do I capture all these arrays in a single DataFrame so that it looks like below:
[[0,0,0,0,1,0,0,0,1]] --- #row 1 in dataframe
[[1,2,3,4,5,6,7,8,9]] --- #row 2 in dataframe
If the same task can be divided further ? There are more thank 500K arrays in the dataset. Thank You