python-2.7

python -m pip install --upgrade pip does not work

笑着哭i 提交于 2021-01-27 05:34:14
问题 Upgrading pip does not do anything, just tells me to upgrade Pip again and that the requirements are satisfied--however, I am on an old pip version. This is Python27, I get the same issue whether I am in a virtual environment or not. Output: C:\Python27>python -m pip install --upgrade pip Requirement already up-to-date: pip in c:\python27\lib\site-packages You are using pip version 9.0.1, however version 19.1.1 is available. You should consider upgrading via the 'python -m pip install -

python -m pip install --upgrade pip does not work

一曲冷凌霜 提交于 2021-01-27 05:34:10
问题 Upgrading pip does not do anything, just tells me to upgrade Pip again and that the requirements are satisfied--however, I am on an old pip version. This is Python27, I get the same issue whether I am in a virtual environment or not. Output: C:\Python27>python -m pip install --upgrade pip Requirement already up-to-date: pip in c:\python27\lib\site-packages You are using pip version 9.0.1, however version 19.1.1 is available. You should consider upgrading via the 'python -m pip install -

Using np.where to find matching row in 2D array

↘锁芯ラ 提交于 2021-01-27 05:26:33
问题 I would like to know how I use np.where with 2D array I have the following array: arr1 = np.array([[ 3., 0.], [ 3., 1.], [ 3., 2.], [ 3., 3.], [ 3., 6.], [ 3., 5.]]) I want to find this array: arr2 = np.array([3.,0.]) But when I use np.where() : np.where(arr1 == arr2) It returns: (array([0, 0, 1, 2, 3, 4, 5]), array([0, 1, 0, 0, 0, 0, 0])) I can't understand what it means. Can someone explain this for me? 回答1: You probably wanted all rows that are equal to your arr2 : >>> np.where(np.all(arr1

Deal with Postgresql Error -canceling statement due to conflict with recovery- in psycopg2

拈花ヽ惹草 提交于 2021-01-27 05:26:26
问题 I'm creating a reporting engine that makes a couple of long queries over a standby server and process the result with pandas. Everything works fine but sometimes I have some issues with the execution of those queries using a psycopg2 cursor: the query is cancelled with the following message: ERROR: cancelling statement due to conflict with recovery Detail: User query might have needed to see row versions that must be removed I was investigating this issue PostgreSQL ERROR: canceling statement

Deal with Postgresql Error -canceling statement due to conflict with recovery- in psycopg2

烂漫一生 提交于 2021-01-27 05:25:46
问题 I'm creating a reporting engine that makes a couple of long queries over a standby server and process the result with pandas. Everything works fine but sometimes I have some issues with the execution of those queries using a psycopg2 cursor: the query is cancelled with the following message: ERROR: cancelling statement due to conflict with recovery Detail: User query might have needed to see row versions that must be removed I was investigating this issue PostgreSQL ERROR: canceling statement

Apply Mask Array 2d to 3d

为君一笑 提交于 2021-01-27 05:07:26
问题 I want to apply a mask of 2 dimensions (an NxM array) to a 3 dimensional array (a KxNxM array). How can I do this? 2d = lat x lon 3d = time x lat x lon import numpy as np a = np.array( [[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]], [[ 9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]]]) b = np.array( [[ 0, 1, 0], [ 1, 0, 1], [ 0, 1, 1]]) c = np.ma.array(a, mask=b) # this behavior is wanted 回答1: There are quite a few different ways to choose from. What you want to do

Formatting date labels on bar plot

二次信任 提交于 2021-01-27 04:52:14
问题 My question Suppose I have a Series like this. In[10]: month_series Out[10]: 2016-01-01 4880 2016-02-01 4579 2016-03-01 6726 2016-04-01 1778 2016-05-01 3303 2016-06-01 5402 2016-07-01 1207 2016-08-01 6176 2016-09-01 5586 2016-10-01 2802 2016-11-01 6944 2016-12-01 3580 2017-01-01 9336 dtype: int64 I want to just construct a bar plot to compare month to month, which seems quite simple with In[11]: month_series.plot(kind='bar') Out[11]: I really don't need anything much more than that, but my

Adding hours to unix time stamp in python

蹲街弑〆低调 提交于 2021-01-27 04:12:18
问题 I need to add 5 hours to a certain unix time stamp. Its like start and stop time for a game. So I have the knowledge of start time and the duration of the game. I need to put end time. How this can be done in python? 回答1: UNIX timestamps are in second units. end_timestamp = start_timestamp + 5 * 60 * 60 回答2: Could be explicit and work with the following: >>> from datetime import timedelta, datetime >>> a = datetime.fromtimestamp(0) >>> b = a + timedelta(hours=5) >>> c = time.mktime(b

Python: How to detect unused packages and remove them

扶醉桌前 提交于 2021-01-26 20:36:34
问题 I use pip freeze > requirements.txt to gather all packages I installed. But after developing many days, some packages are now unused. How can I find these unused packages and remove them, to make my project more clear? 回答1: Inside Pycharm Go to code > inspect code Select Whole project option and click OK. In inspection results panel locate Package requirements section under Python (note that this section will be showed only if there is any requirements.txt or setup.py file). The section will

Python: How to detect unused packages and remove them

旧时模样 提交于 2021-01-26 20:36:32
问题 I use pip freeze > requirements.txt to gather all packages I installed. But after developing many days, some packages are now unused. How can I find these unused packages and remove them, to make my project more clear? 回答1: Inside Pycharm Go to code > inspect code Select Whole project option and click OK. In inspection results panel locate Package requirements section under Python (note that this section will be showed only if there is any requirements.txt or setup.py file). The section will