Re: [Pytables-users] modifying a table column

2013-08-27 Thread Anthony Scopatz
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


On Tue, Aug 27, 2013 at 11:44 AM, Oleksandr Huziy guziy.sa...@gmail.comwrote:

 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=58040911iu=/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=58040911iu=/4140/ostg.clktrk___
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users


Re: [Pytables-users] modifying a table column

2013-08-27 Thread Oleksandr Huziy
Thank you Anthony.

Cheers


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


 On Tue, Aug 27, 2013 at 11:44 AM, Oleksandr Huziy 
 guziy.sa...@gmail.comwrote:

 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=58040911iu=/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=58040911iu=/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=58040911iu=/4140/ostg.clktrk___
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users


Re: [Pytables-users] modifying a table column

2013-08-27 Thread Anthony Scopatz
On Tue, Aug 27, 2013 at 6:50 PM, Oleksandr Huziy guziy.sa...@gmail.comwrote:

 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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/4140/ostg.clktrk___
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users


Re: [Pytables-users] modifying a table column

2013-08-27 Thread Oleksandr Huziy
2013/8/27 Anthony Scopatz scop...@gmail.com


 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 * m, uservars = {c: c, m: coef })
 expr.set_output(c)
 expr.eval()
 varTable.flush()
 h.close()


Aha, this is cool. Thanks Anthony.

Cheers
--
Sasha



  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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/4140/ostg.clktrk___
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users


Re: [Pytables-users] modifying a table column

2013-08-27 Thread Anthony Scopatz
Glad I could help!


On Tue, Aug 27, 2013 at 7:44 PM, Oleksandr Huziy guziy.sa...@gmail.comwrote:

 2013/8/27 Anthony Scopatz scop...@gmail.com


 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 * m, uservars = {c: c, m: coef })
 expr.set_output(c)
 expr.eval()
 varTable.flush()
 h.close()


 Aha, this is cool. Thanks Anthony.

 Cheers
 --
 Sasha



  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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/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=58040911iu=/4140/ostg.clktrk___
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users