Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53656

Re: Broadcasting TimeSeries

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.05; '(of': 0.07; 'attribute': 0.07; 'problem?': 0.07; '(currently': 0.09; 'happen?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'windows,': 0.09; 'python': 0.11; 'def': 0.12; 'bug': 0.12; 'jan': 0.12; 'wrote': 0.14; '2.7': 0.14; '(without': 0.16; '60,': 0.16; 'davide': 0.16; 'filename,': 0.16; 'idle,': 0.16; 'idle.': 0.16; 'idlelib': 0.16; 'ignoring': 0.16; 'numpy': 0.16; 'once.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'stderr': 0.16; 'index': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'mechanism': 0.19; 'command': 0.22; '>>>': 0.22; 'import': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'skip:" 30': 0.26; 'defined': 0.27; 'skip:_ 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'fixed': 0.29; 'skip:( 20': 0.30; '"",': 0.31; '>>>>': 0.31; 'catching': 0.31; 'file': 0.32; 'run': 0.32; 'running': 0.33; '(most': 0.33; 'skip:_ 10': 0.34; 'problem': 0.35; 'skip:s 30': 0.35; 'there': 0.35; 'idle': 0.36; 'skip:" 50': 0.36; 'skip:f 40': 0.36; 'next': 0.36; 'two': 0.37; 'starting': 0.37; 'window': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'recent': 0.39; 'does': 0.39; '(from': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'received:173': 0.61; 'times': 0.62; 'soon': 0.63; 'finally': 0.65; 'believe': 0.68; 'prompt': 0.68; 'overcome': 0.74; '3.4': 0.84; 'answered,': 0.84; 'received:fios.verizon.net': 0.84; 'warning.': 0.84; 'works!': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Broadcasting TimeSeries
Date Wed, 04 Sep 2013 18:00:06 -0400
References <6b13a66f-ff9a-4f82-b2d1-2231b8f4e94e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To <6b13a66f-ff9a-4f82-b2d1-2231b8f4e94e@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.65.1378332020.5461.python-list@python.org> (permalink)
Lines 75
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378332020 news.xs4all.nl 15910 [2001:888:2000:d::a6]:38530
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53656

Show key headers only | View raw


On 9/4/2013 4:06 PM, Davide Dalmasso wrote:

> I opened my Python Shell and I wrote the following:

This is with Idle. I believe you are running on Windows.

>>>> import numpy as np
>>>> import pandas as pd
>
> then I made a function
>
>>>> def afunc(aframe):
>      return aframe - aframe.mean(axis=1)
>
> and I defined a DataFrame with time as index
>
>>>> A = pd.DataFrame(np.random.randn(5,3),columns=['a','b','c'],index=pd.date_range(start='1984-12-20',periods=5))
>>>> A
>                     a         b         c
> 1984-12-20 -0.257916 -0.137923 -0.669796
> 1984-12-21 -1.632874 -1.850365  1.571715
> 1984-12-22  1.185828 -0.149839 -1.565930
> 1984-12-23 -0.757311  0.034627  0.794608
> 1984-12-24  0.548785 -1.126786 -0.438457
>
> now, if I call the function the following error is generated:
>
>>>> afunc(A)
> Traceback (most recent call last):
>    File "<pyshell#6>", line 1, in <module>
>      afunc(A)
>    File "<pyshell#3>", line 2, in afunc
>      return aframe - aframe.mean(axis=1)
>    File "C:\Python33\lib\site-packages\pandas\core\frame.py", line 217, in f
>      return self._combine_series(other, na_op, fill_value, axis, level)
>    File "C:\Python33\lib\site-packages\pandas\core\frame.py", line 3601, in _combine_series
>      return self._combine_series_infer(other, func, fill_value)
>    File "C:\Python33\lib\site-packages\pandas\core\frame.py", line 3619, in _combine_series_infer
>      FutureWarning)
>    File "C:\Python33\lib\idlelib\PyShell.py", line 60, in idle_showwarning
>      file.write(warnings.formatwarning(message, category, filename,
> AttributeError: 'NoneType' object has no attribute 'write'

This was a bug in Idle when run directly on Windows, from Start or an 
icon. In this circumstance, there is no stderr stream to write to. I 
fixed it last June by catching the AttributeError and ignoring the 
warning. The fix will be in the next 2.7 and 3.3 releases and is in the 
3.4 releases (currently 0a1, soon 0a2).

The problem (of no stderr) is avoided now, while still using Idle, by 
starting Idle from a Command Prompt window (Start/Accessories):
   python -m idlelib
or by starting the standard interpreter (from Start or icon) and entering
   >>> import idlelib.idle

> then I recall the same function (without any change) and the function works!

pandas must have a mechanism to only issue the warning once.

>>>> afunc(A)
>                     a         b         c
> 1984-12-20  0.097295  0.217289 -0.314584
> 1984-12-21 -0.995699 -1.213190  2.208890
> 1984-12-22  1.362475  0.026808 -1.389283
> 1984-12-23 -0.781285  0.010652  0.770633
> 1984-12-24  0.887604 -0.787967 -0.099637
>
> Why does this happen? Why I must call the function two times before it finally works?
> How can I overcome this problem?

Answered, I believe.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Broadcasting TimeSeries Davide Dalmasso <davide.dalmasso@gmail.com> - 2013-09-04 13:06 -0700
  Re: Broadcasting TimeSeries Terry Reedy <tjreedy@udel.edu> - 2013-09-04 18:00 -0400

csiph-web