Extracting f0
x = store['spl20130409_107-6']
f0 = x.Freq[(x.SPL == max(x.SPL))]
:)
Extracting a results set by frequency range and node number from a store object (a dataFrame)
storeName = root + '20121205-WEEaxisymConstDispSettleTimes.h5'
store = pd.HDFStore(storeName)
x = store['ball70_p']
f = x.Freq[(x.Node == 32) & (x.Freq > fmin) & (x.Freq < fmax)].values
p = abs(x.Pressure[(x.Node == 32) & (x.Freq > fmin) & (x.Freq < fmax)]).values
store.close()
My observations suggest the store is volatile: it should be closed when not in use to prevent database failure in case of, say,
power failure. So it seems an open and close should be used in each ipython cell. Wrap with, the open and close functions.
This seems clunky. :(
Creating a dataFrame with column based data and appending new results without new columns, with sort based on one of the columns.
for i in [4]:
a = mfile.File(root2 + '1_hw%i.O07' % i); a.load()
b = pd.DataFrame(a.pressures, columns = ['Freq', 'Node', 'Pressure'])
c = store['v22_1_p'].append(b)
c = c.sort_index(by = 'Freq')
store['v22_1_p'] = c
Creating a multicolumn dataFrame with labels.
b = pd.DataFrame(array([x0[0, 1:], x0[1, 1:], x0[2, 1:], x0[3, 1:], x0[4, 1:]]).transpose(),
columns = ['Time', 'pNode4', 'pNode31', 'pNode32', 'pNode11', 'dNode35'])
Deleting an item in the store:
store.remove(keyName)
Adding a column to a dataFrame: (this does not work with the store)
b = pd.DataFrame(Q, columns = ['f0', 'DisplacementAtF0', 'Q']) # create
b['newCol'] = listVariable # append column
Printing a whole dataframe or specific columns
print melamine5cm.to_string()
No comments:
Post a Comment