On Tue, Aug 27, 2013 at 6:50 PM, Oleksandr Huziy <guziy.sa...@gmail.com>wrote:

> Hi Again:
>
>
> 2013/8/27 Anthony Scopatz <scop...@gmail.com>
>
>> Hey Sasha,
>>
>> You probably want to look at the Expr class [1] where you set "out" to be
>> the same as the original array.
>>
>> Be Well
>> Anthony
>>
>> 1. http://pytables.github.io/usersguide/libref/expr_class.html
>>
>
>
> I just wanted to make sure if it is possible to use an assignment in
> expressions? (this gives me a syntax error exception, complains about the
> equal sign in the expression)
>

Hi Sasha,

Assignment is a statement not an expression, so it is not possible to use
here.  This is why you are getting a syntax error.


>
>     h = tb.open_file(path, mode="a")
>     varTable = h.get_node("/", var_name)
>     coef = 3 * 60 * 60 #output step
>     expr = tb.Expr("c = c * m", uservars = {"c": varTable.cols.field, "m":
> coef })
>     expr.eval()
>     varTable.flush()
>     h.close()
>
> Is this an optimal way of multiplying a column? (this one works, but I
> think it loads all the data into memory...right?)
>
>     expr = tb.Expr("c * m", uservars = {"c": varTable.cols.field, "m":
> coef })
>     varTable.cols.field[:] = expr.eval()
>

You are right that this loads the entire computed array into memory and is
therefore not optimal.  I would do something like the following:

h = tb.open_file(path, mode="a")
varTable = h.get_node("/", var_name)
coef = 3 * 60 * 60 #output step
c = varTable.cols.field
expr = tb.Expr("c = c * m", uservars = {"c": c, "m": coef })
expr.set_output(c)
expr.eval()
varTable.flush()
h.close()

Be Well
Anthony


>
> Thank you
>
> Cheers
>
>
>>
>>
>>  On Tue, Aug 27, 2013 at 11:44 AM, Oleksandr Huziy <guziy.sa...@gmail.com
>> > wrote:
>>
>>>  Hi All:
>>>
>>> I have a huge table imported from other binary files to hdf, and I
>>> forgot to multiply the data by a factor in one case. Is there an easy way
>>> to multiply a column by a constant factor using pytables?
>>> To modify it in place?
>>>
>>> Thank you
>>>
>>> --
>>> Sasha
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
>>> Discover the easy way to master current and previous Microsoft
>>> technologies
>>> and advance your career. Get an incredible 1,500+ hours of step-by-step
>>> tutorial videos with LearnDevNow. Subscribe today and save!
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Pytables-users mailing list
>>> Pytables-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/pytables-users
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
>> Discover the easy way to master current and previous Microsoft
>> technologies
>> and advance your career. Get an incredible 1,500+ hours of step-by-step
>> tutorial videos with LearnDevNow. Subscribe today and save!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Pytables-users mailing list
>> Pytables-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pytables-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
> _______________________________________________
> Pytables-users mailing list
> Pytables-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pytables-users
>
>
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to