Dav Clark
2016-05-17 22:40:00 UTC
Scopatz already seemingly answered this question here:
https://groups.google.com/forum/#!searchin/pytables-users/sum$20column/pytables-users/1_DV1gC6YIk/KT0tuH4ajdYJ
So, I tried some stuff. None of it works in a way that makes sense. For
example, i have a table in `spy`:
```
# This works and computes what I want, taking a few seconds for something
# I need to do this literally gabillions of times
np.mean(list(x['Bid_Price'] for x in spy.iterrows()))
# These are errors
tb.Expr('sum(spy.cols.Bid_Price)')
tp.Expr('sum(spy["Bid_Price"])')
# So I get the column in a variable:
spy_bp = spy.cols.Bid_Price
# This returns the column - each element
tb.Expr('sum(spy_bp)')
# These are "ValueError: reduction axis is out of bounds"
tb.Expr('sum(spy_bp, axis=0)')
tb.Expr('sum(spy_bp, axis=2)')
# So I can do this...
tb.Expr('sum(spy_bp)').eval().sum()
# But that's bizarre and also slower than the first line above
# This is also slower (but does the same general thing)
tb.Expr('spy_bp').eval().sum()
```
So what was Scopatz suggesting in the above link?
Best,
D
https://groups.google.com/forum/#!searchin/pytables-users/sum$20column/pytables-users/1_DV1gC6YIk/KT0tuH4ajdYJ
So, I tried some stuff. None of it works in a way that makes sense. For
example, i have a table in `spy`:
```
# This works and computes what I want, taking a few seconds for something
# I need to do this literally gabillions of times
np.mean(list(x['Bid_Price'] for x in spy.iterrows()))
# These are errors
tb.Expr('sum(spy.cols.Bid_Price)')
tp.Expr('sum(spy["Bid_Price"])')
# So I get the column in a variable:
spy_bp = spy.cols.Bid_Price
# This returns the column - each element
tb.Expr('sum(spy_bp)')
# These are "ValueError: reduction axis is out of bounds"
tb.Expr('sum(spy_bp, axis=0)')
tb.Expr('sum(spy_bp, axis=2)')
# So I can do this...
tb.Expr('sum(spy_bp)').eval().sum()
# But that's bizarre and also slower than the first line above
# This is also slower (but does the same general thing)
tb.Expr('spy_bp').eval().sum()
```
So what was Scopatz suggesting in the above link?
Best,
D
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.