Jul-10-2019, 07:43 AM
(This post was last modified: Jul-10-2019, 07:56 AM by python_newbie09.)
(Jul-10-2019, 12:17 AM)scidam Wrote: There are lots of questions here: What areB, D, F
in line #6? what means 'xxx.hdf', why did you usekey[0:-4]
, are all of your keys have length 5? Did you usepd.concat
somewhere in your code? Should'xxx.hdf'.format(key[0:-4])
be something like'{}.hdf'.format(key)
?
B, D, F are separate arrays that were concatenated and appended to an array for each feature. 'A', 'C' and 'E' are the columns names. Sorry for the vague names but just for the sake of preserving the data confidentiality.
xxx.hdf is the file name that I want to give for each of the dataframe created and this name is derived from the key value in the dictionary. It is supposed to be df.to_hdf('C:\...\....\{}.hdf'.format(key[0:-4]),mode='w', key='df'). key[0:-4] allows me to extract only the key name upto before the last 4 characters (to remove '.csv') in the end of the key value. So originally the key values are filea.csv, fileb.csv and filec.csv
I hope this explains.
I think what is happening is the arrays that are getting appended are not getting removed so I do not know if I will be doing the right thing to add the code below after saving the dataframe:
del(B) del(D) del(F)or if there is a more efficient way to reset these arrays?
alright, i have solved my problem. I placed creating the empty arrays in the beginning of the code to be after the first for loop instead of having it before the first for loop so that every time it loops, a new set of empty arrays is created. I guess I just needed a break and your questions to think through! Thanks!