Animated functions with matplotlib
I am trying to plot a live signal using matplotlib and it really drives me crazy. I have tried dozens of variants, with and without interactive (plt.ion()), with animation.FuncAnimation and doing things by hand, calling plt.show() and/or plt.draw() but nothing works as expected. One problem is that running commands in the interactive python shell behaves differently from the behavior when using the same commands in a script, so trying out different versions is very confusing. I'd like to do something like this: fig, ax = plt.subplots() ival = .1 now = 0 t = list(numpy.linspace(now, now, 500)) y = [0] * len(t) while True: time.sleep(ival) now += ival val = get_sample_from_some_signal() t = t[1:] + [now] y = y[1:] + [val] ax.clear() ax.plot(t, y) plt.pause(1e-9) This works but is *very* slow and it seems the plot window is closed and opened again or raised for each new value to plot. I have tried to call plt.show(block=False) only once and then repeatedly only change data with ax.lines[0].set_xdata(), ax.lines[0].set_ydata(), and ax.set_xlim() and then calling plt.draw(). That works in the interactive python shell but not in a script. When calling set[xy]_data() and set_xlim() in an amimate() function passed to animation.FuncAnimation, but I haven't managed to redraw the x scale values (although ax.xlim() is called). Also, with animation.FuncAnimation() I loose control of the main thread of execution. When calling plt.show() the function doesn't return. I may want to change the loop so that instead of time.sleep(ival) val = get_sample_from_some_signal() I would have val = wait_for_next_same_from_some_signal() and I think this doesn't work with FuncAnimation since that calls the passed function with a fixed time interval. I am completely lost, can someone help? Steve -- https://mail.python.org/mailman/listinfo/python-list
Division issue with 3.8.2 on AIX 7.1
I've built Python 3.8.2 on AIX 5.2, 5.3, 6.1, and 7.1. I am seeing different results for the following Python program: $ python3 -c "eps = 2.0 ** -53.0; tiny = 2.0 ** -1022.0; \ print ((1.0 - eps) / tiny * 4.0)" I get the correct result, 1.7976931348623157e+308, on AIX 5.2, 5.3, and 6.1. But, on 7.1, I get "inf". Anyone know where can I look in the Python source code to investigate this? -- albert chin (ch...@thewrittenword.com) -- https://mail.python.org/mailman/listinfo/python-list
From an existing Pandas DataFrame, how can I create a summary DataFrame based on the union of overlapping date ranges (given a start and an end date) and an additional column?
Hello, Given a dateframe with trips made by employees of different companies, I am trying to generate a new dataframe with only the company names. I am looking to combine the overlapping travel times from employees of the SAME company into a single row. If there are no overlapping travel times, then that row just transfers over as-is. When there are overlapping travel times, then the following will happen: --The name field is removed b/c that is no longer relevant (company name stays), the Depart date will be the earliest date of any of the trip dates regardless of the employee, the Return date will be the latest date of any of the trip dates regardless of the employee, the charges for the trip will be summed For example, if trips had dates 01/01/20 - 01/31/20, 01/15/20 - 02/15/20, 02/01-20 - 02/28/20, then all three would be combined. The starting date will be 1/1/20 and ending as of 2/28/20. Basically, the company was on that trip from start to finish… kinda like a relay run handing off the baton. Also, the charges will be summed for each of those trips and transferred over to the single row. Here is the starting dataframe code/output (note: the row order is typically not already sorted by company name as in this example): import pandas as pd emp_trips = {'Name': ['Bob','Joe','Sue','Jack', 'Henry', 'Frank', 'Lee', 'Jack'], 'Company': ['ABC', 'ABC', 'ABC', 'HIJ', 'HIJ', 'DEF', 'DEF', 'DEF'], 'Depart' : ['01/01/2020', '01/01/2020', '01/06/2020', '01/01/2020', '05/01/2020', '01/13/2020', '01/12/2020', '01/14/2020'], 'Return' : ['01/31/2020', '02/15/2020', '02/20/2020', '03/01/2020', '05/05/2020', '01/15/2020', '01/30/2020', '02/02/2020'], 'Charges': [10.10, 20.25, 30.32, 40.00, 50.01, 60.32, 70.99, 80.87] } df = pd.DataFrame(emp_trips, columns = ['Name', 'Company', 'Depart', 'Return', 'Charges']) # Convert to date format df['Return']= pd.to_datetime(df['Return']) df['Depart']= pd.to_datetime(df['Depart']) Name Company Depart Return Charges0Bob ABC 2020-01-01 2020-01-3110.101Joe ABC 2020-01-01 2020-02-15 20.252Sue ABC 2020-01-06 2020-02-2030.323 Jack HIJ 2020-01-01 2020-03-0140.004 Henry HIJ 2020-05-01 2020-05-05 50.015 Frank DEF 2020-01-13 2020-01-1560.326Lee DEF 2020-01-12 2020-01-3070.997 Jack DEF 2020-01-14 2020-02-02 80.87 And, here is the desired/generated dataframe: Company Depart Return Charges0 ABC 01/01/2020 02/20/202060.671 HIJ 01/01/2020 03/01/202040.002 HIJ 05/01/2020 05/05/202050.013 DEF 01/12/2020 02/02/2020 212.18 I have been trying to use a combination of sorting and grouping but the best I've achieved is reordering the dataframe. Even though I am able to sort/group based on values, I still run into the issues of finding overlapping date ranges and pulling out all trips based on a single company per aggregate/overlapping date range. Thank you in advance for any help! Aaron -- https://mail.python.org/mailman/listinfo/python-list
Re: Division issue with 3.8.2 on AIX 7.1
> Anyone know where can I look in the Python source code to investigate > this? Probably around https://github.com/python/cpython/blob/master/Objects/floatobject.c -- https://mail.python.org/mailman/listinfo/python-list
Trouble with making modules 'global'
Hi, I am struggling with making modules global for all definitions in my code. I faced the problem with the pyomo modules but can generate the error with pandas too. The model structure looks as follow: I have 3 '.py' files each of them containing definitions. The first controls inputs and outputs and starts an optimization.py file ( optimization.py). Within optimization.py I call a third .py file (model.py) that includes a series of definitions, representing mathematical equations of a optimization model. (1) Main.py import pandas as pd def main_part() ... Result = optimization_def(x,y,z) ... (2) Optimization.py def optimization(x_l,y_l,z_l) ... O = obejctive(x_l,y_l) ... (3) Model.py def objctive(x_a,x_b) ... def constraint(x_a,z_a) I do not understand why pd is not known in def optimization() as well as in objctive(). I tried to make it global by adding global pd in Main.py I would appreciate any support. Thanks in advance Frank -- https://mail.python.org/mailman/listinfo/python-list
Re: Division issue with 3.8.2 on AIX 7.1
On Wed, Jun 03, 2020 at 08:11:17PM -0400, Dennis Lee Bieber wrote: > On Tue, 2 Jun 2020 12:26:16 -0500, Albert Chin > declaimed the following: > > >I've built Python 3.8.2 on AIX 5.2, 5.3, 6.1, and 7.1. I am seeing > >different results for the following Python program: > > $ python3 -c "eps = 2.0 ** -53.0; tiny = 2.0 ** -1022.0; \ > >print ((1.0 - eps) / tiny * 4.0)" > > > >I get the correct result, 1.7976931348623157e+308, on AIX 5.2, 5.3, > >and 6.1. But, on 7.1, I get "inf". > > > >Anyone know where can I look in the Python source code to investigate > >this? > > Have you considered that it might be something in an underlying C > library (especially for the double-precision exponentiation)? On Wed, Jun 03, 2020 at 08:44:47PM -0700, Miki Tebeka wrote: > > Anyone know where can I look in the Python source code to investigate > > this? > > Probably around > https://github.com/python/cpython/blob/master/Objects/floatobject.c Thanks to both of you. I applied some updated OS patches and the problem went away. -- albert chin (ch...@thewrittenword.com) -- https://mail.python.org/mailman/listinfo/python-list
Re: Trouble with making modules 'global'
I just realized that the problem is related to python 3.8 and not to 3.7. Am Donnerstag, 4. Juni 2020 05:48:31 UTC+2 schrieb pyth...@gmail.com: > Hi, > > I am struggling with making modules global for all definitions in my code. > I faced the problem with the pyomo modules but can generate the error with > pandas too. > > The model structure looks as follow: > > I have 3 '.py' files each of them containing definitions. The first controls > inputs and outputs and starts an optimization.py file ( optimization.py). > Within optimization.py I call a third .py file (model.py) that includes a > series of definitions, representing mathematical equations of a optimization > model. > > > > (1) Main.py > import pandas as pd > > def main_part() > ... Result = optimization_def(x,y,z) > ... > > (2) Optimization.py > def optimization(x_l,y_l,z_l) > ... O = obejctive(x_l,y_l) > ... > > (3) Model.py > def objctive(x_a,x_b) > ... > def constraint(x_a,z_a) > > > > I do not understand why pd is not known in def optimization() as well as in > objctive(). > I tried to make it global by adding global pd in Main.py > > > I would appreciate any support. Thanks in advance > Frank -- https://mail.python.org/mailman/listinfo/python-list
Issues with Python
Keep getting an error when trying to us Python with Pycharm. I uninstalled it but this was the error I received. Sent from [1]Mail for Windows 10 References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 -- https://mail.python.org/mailman/listinfo/python-list
Re: Division issue with 3.8.2 on AIX 7.1
I need off this list please. I don’t even have this. On Wed, Jun 3, 2020 at 11:30 PM Albert Chin < python-l...@mlists.thewrittenword.com> wrote: > On Wed, Jun 03, 2020 at 08:11:17PM -0400, Dennis Lee Bieber wrote: > > On Tue, 2 Jun 2020 12:26:16 -0500, Albert Chin > > declaimed the following: > > > > >I've built Python 3.8.2 on AIX 5.2, 5.3, 6.1, and 7.1. I am seeing > > >different results for the following Python program: > > > $ python3 -c "eps = 2.0 ** -53.0; tiny = 2.0 ** -1022.0; \ > > >print ((1.0 - eps) / tiny * 4.0)" > > > > > >I get the correct result, 1.7976931348623157e+308, on AIX 5.2, 5.3, > > >and 6.1. But, on 7.1, I get "inf". > > > > > >Anyone know where can I look in the Python source code to investigate > > >this? > > > > Have you considered that it might be something in an underlying C > > library (especially for the double-precision exponentiation)? > > On Wed, Jun 03, 2020 at 08:44:47PM -0700, Miki Tebeka wrote: > > > Anyone know where can I look in the Python source code to investigate > > > this? > > > > Probably around > > https://github.com/python/cpython/blob/master/Objects/floatobject.c > > Thanks to both of you. I applied some updated OS patches and the > problem went away. > > -- > albert chin (ch...@thewrittenword.com) > -- > https://mail.python.org/mailman/listinfo/python-list > -- Mrs. Sherry West Owens Cross Roads Elementary -- https://mail.python.org/mailman/listinfo/python-list
Unsubscribe to python list
I want to unsubscribe from python list and would like to stop recieving mails from the same. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unsubscribe to python list
On 4/06/20 4:59 PM, Meet Agrawal wrote: I want to unsubscribe from python list and would like to stop recieving mails from the same. At the bottom of your request (as reflected), this, and all over messages to the list is an administration link. At the foot of that web-page you will find a space to unsubscribe your email address (admittedly, I've not tried it). -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Issues with Python
On 4/06/20 2:22 PM, Kelley Hudson wrote: Keep getting an error when trying to us Python with Pycharm. I uninstalled it but this was the error I received. Sent from [1]Mail for Windows 10 References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 Many folk are security-conscious and will not click on links provided by unknown people (apologies for sounding unfriendly). Recommend you copy-paste the exact message into an email (also request a descriptive Subject: which will help anyone with a similar problem to search the archives). Also, it may help to know the OpSys (assuming MS-Windows), the version of Python, and that of the Pycharm IDE... Meantime, the Pycharm folk have invested considerable time and effort in their on-line manual. Is there an answer there about how to link particular (versions) Python interpreters to the current project? -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list