numpy

Keep getting this error using numpy.piecewise to get segmented linear regression

孤街浪徒 提交于 2021-01-28 11:00:28
问题 I have a very large datafile, where x= time and y= distance. I would like to figure out what the speed is in different segments. Ideally, I would like Python to calculate the segments and the corresponding linear regression functions. I googled this and think my best option is using the numpy.piecewise to get segmented linear regression. I only keep getting this error # Remove full_output from kwargs, otherwise we're passing it in twice'. The code is use is as follows: y = cleandata["Distance

How to install numpy with PyCharm on mac OSX?

元气小坏坏 提交于 2021-01-28 10:10:59
问题 I downloaded the binary file and all it does is open up PyCharm. How can I install? Many thanks. 回答1: I ran into the same problem. And I solved it like this: File/Default Settings... Chose Default Project/Project Interpreter Chose the version of Python you are working with from the popup menu Project Interpreter. Below the list click on the '+' button. Find your way in the huge list of Packages available to find 'numpy' and install it. There is probably another way to make it per project, but

How to change integer type when creating meshgrid with Numpy?

这一生的挚爱 提交于 2021-01-28 10:10:37
问题 I got the following error MemoryError: Unable to allocate 201. GiB for an array with shape (2999, 2999, 2999) and data type int64 when creating a meshgrid with Numpy using the following code dimension=3 tot_length=2000 list_no=range(1, tot_length) arr = np.meshgrid ( *[list_no for _ in range ( dimension )] ) May I know where to change the int64 to int32 or, other possible setting that can allow me to maximize the number of tot_length which is higher than the value 2000 I have check the

OpenCV+Python getting this error when trying to run the code on bigger images

坚强是说给别人听的谎言 提交于 2021-01-28 10:04:48
问题 I am getting this error when running my code through a set of big images of 5472 x 3648 dimension(4.4mb) . The code is working fine when my images were around 1437 x 1243 dimension, I can run through all images and save it. Notice: You can see with bigger images, I still managed to run the first file and save it to 1771, it only shown error and stop the run halfway through 1772. Is there anyway which I can process my images using this algorithm without needing to resize the images dimension?

Numpy: Diff on non-adjacent values

走远了吗. 提交于 2021-01-28 09:46:41
问题 I'd like to take the difference of non-adjacent values within a 1D numpy array. The array is a selection of values along a timeline from 1 to N . For N=12 , the array could look like timeline = np.array([ 0, np.nan, np.nan, 4, np.nan, 6, np.nan, np.nan, 9, np.nan, 11, 12]) or like timeline = np.array([ 0, 0, 0, 4, 0, 6, 0, 0, 9, 0, 11, 12]) The desired result should look like: (size of array is intact and position is important) diff = np.array([ 0, 0, 0, 4, 0, 2, 0, 0, 3, 0, 2, 1]) np.diff

Find percentile in pandas dataframe based on groups

眉间皱痕 提交于 2021-01-28 09:45:48
问题 Season Name value 2001 arkansas 3.497 2002 arkansas 3.0935 2003 arkansas 3.3625 2015 arkansas 3.766 2001 colorado 2.21925 2002 colorado 1.4795 2010 colorado 2.89175 2011 colorado 2.48825 2012 colorado 2.08475 2013 colorado 1.68125 2014 colorado 2.5555 2015 colorado 2.48825 In the dataframe above, I want to identify top and bottom 10 percentile values in column value for each state (arkansas and colorado). How do I do that? I can identify top and bottom percentile for entire value column like

Find percentile in pandas dataframe based on groups

≯℡__Kan透↙ 提交于 2021-01-28 09:42:51
问题 Season Name value 2001 arkansas 3.497 2002 arkansas 3.0935 2003 arkansas 3.3625 2015 arkansas 3.766 2001 colorado 2.21925 2002 colorado 1.4795 2010 colorado 2.89175 2011 colorado 2.48825 2012 colorado 2.08475 2013 colorado 1.68125 2014 colorado 2.5555 2015 colorado 2.48825 In the dataframe above, I want to identify top and bottom 10 percentile values in column value for each state (arkansas and colorado). How do I do that? I can identify top and bottom percentile for entire value column like

Numpy: Diff on non-adjacent values

可紊 提交于 2021-01-28 09:42:07
问题 I'd like to take the difference of non-adjacent values within a 1D numpy array. The array is a selection of values along a timeline from 1 to N . For N=12 , the array could look like timeline = np.array([ 0, np.nan, np.nan, 4, np.nan, 6, np.nan, np.nan, 9, np.nan, 11, 12]) or like timeline = np.array([ 0, 0, 0, 4, 0, 6, 0, 0, 9, 0, 11, 12]) The desired result should look like: (size of array is intact and position is important) diff = np.array([ 0, 0, 0, 4, 0, 2, 0, 0, 3, 0, 2, 1]) np.diff

np.array2string not removing brackets around an array

試著忘記壹切 提交于 2021-01-28 09:41:01
问题 I have been attempting to extract data from excel files, convert it into an array, then write it into some other currently undefined file type (so a .txt file is the current placeholder file type). I'm sure the code is rather ugly, but it works: import os import pandas as pd import glob import numpy as np def xlxtract(): for filename in glob.glob('*.xlsx'): ExcelFile = filename[:-5] RosewoodData = pd.read_excel(ExcelFile + '.xlsx') DataMatrix = np.array(RosewoodData) DataMatrixString = np

Understanding the use of any() and all() in numpy arrays

喜你入骨 提交于 2021-01-28 09:38:19
问题 What's the difference between the following: a = np.array([2,3,4]) b = np.array([2,7,8]) if a.any() == b.all(): print('yes') and a = np.array([2,3,4]) b = np.array([2,7,8]) if a.any() == b.any(): print('yes') In both situations, 'yes' is printed. 回答1: any() and all() are intended for boolean arrays. any() returns True if there's any values that are equal to True in the array. all() returns True if all values in the array are equal to True . For integers/floats the functionality is similar,