« first day (861 days earlier)      last day (1327 days later) » 

12:46 AM
0
Q: the base-ten value of any input with python

Motoko KusanagiTo start off I'd like to note I am aware of int(val, base). My goal was to write a short function capable of taking in a base int, and a string defining the value to be summed. The function rests upon the equation: represented_value = value * base ^ placeholder >>> base_v = lambda base_v, n...

 
 
2 hours later…
2:45 AM
0
Q: Properly shifting irregular time series in Pandas

fredbabaSuppose I have the following data frame: >>> import pandas as pd >>> import numpy as np >>> import time >>> >>> x = np.arange(10) >>> t = time.time() + x + np.random.randn(10) >>> data = pd.DataFrame({"x": x}) >>> data.index = pd.to_datetime(1e9 * t) >>> data x 2016-0...

 
3:41 AM
0
Q: Mix three vectors in a numpy array, then sort it

Mauro AssisI have 3 numpy.ndarray vectors, X, Y and intensity. I would like to mix it in an numpy array, then sort by the third column (or the first one). I tried the following code: m=np.column_stack((X,Y)) m=np.column_stack((m,intensity)) m=np.sort(m,axis=2) Then I got the error: ValueError: axis(=2) o...

0
Q: Getting 'av_interleaved_write_frame(): Broken pipe' error

PoornanI am trying this blog post.I am new to python, numpy as well as FFMPEG. I could not figure out what causes this issue. http://zulko.github.io/blog/2013/09/27/read-and-write-video-frames-in-python-using-ffmpeg/ here is the code: import subprocess as sp import numpy print ("Hello World!"); FFMP...

 
4:15 AM
0
Q: Points and Segments Solution

Huy VoTask. Given a set of points on a line and a set of segments on a line. The goal is to compute, for each point, the number of segments that contain this point. Input Format. The first line contains two non-negative integers s and p defining the number of segments and the number of points on a lin...

 
 
1 hour later…
5:16 AM
0
Q: Re-arrange the array contain endpoints to creat an closed polygon in Python

Han ZhengzuFor some purpose, I want to plot an polygon based on several latitude and longitude as endpoints which combined together. The example data shows like this: fig=plt.figure() ax = plt.gca() x_map1, x_map2 = 114.166,114.996 y_map1, y_map2 = 37.798,38.378 map = Basemap(llcrnrlon=x_map1,llcrnrl...

0
Q: Is this the wrong error message - AttributeError: 'int' object has no attribute 'log2'?

TheguyI guess this has to do with integer type overflow. But why the strange error message? In [37]: np.log2(2**63) Out[37]: 63.0 In [38]: np.log2(2**64) Traceback (most recent call last): File "<ipython-input-38-f1b1c814f08c>", line 1, in <module> np.log2(2**64) AttributeError: 'int' object...

 
5:55 AM
0
Q: Pandas: cannot import name adjoin

MerlinFrom Wes: def side_by_side(*objs, **kwds): from pandas.core.common import adjoin space = kwds.get('space', 4) reprs = [repr(obj).split('\n') for obj in objs] print adjoin(space, *reprs) Apply below: import pandas as pd df1 = pd.DataFrame(np.random.rand(10,3)) df2 = pd...

 
6:31 AM
0
Q: How to fit two numpy matrices with Pyspark's SVM?

ml_studentI have two numpy matrices like this: Features: (878049, 6) <type 'numpy.ndarray'> Labels: (878049,) <type 'numpy.ndarray'> I was curious about if I can use Pyspark's random forests to fit the previous mentioned matrices. From the documentation, we have that RF algorithm can be...

 
7:15 AM
0
Q: Ornstein-Uhlenbeck process for calculating half-life for multiple time-series in python

Lost SoulI am currently trying to find the half-life of a basic mean reversion strategy by using the below codes : import pandas as pd import numpy as np import statsmodels.api as sm df1=pd.read_excel('C:\Users\Jai\Desktop\Strat\Formatted Data\ForADF\\tdSpreads.xlsx') Halflife_results={} for col in df...

 
7:44 AM
0
Q: Split dataset into proportional subsets using numpy

DemauntI wonder if there is function like this my_fun(my_list, *arg) where arg is list or proportins every element of *arg is integer value between 0 and 1 sum of arg elements must <=1 for example my_list = ['a','b','c','d','f',1, 2, 3, 4, 5] fun_i_am_looking_for (my_list, 0.4, 0.4, 0.1) result =...

 
 
3 hours later…
10:17 AM
0
Q: ValueError: Color array must be two-dimensional

gllowI would like to plot x1 and x2 scatter graph but the color will be different based on the class which is y y = np.array(df['class']) x1 = np.array(df['clump_thickness']) x2 = np.array(df['bland_chrom']) plt.scatter(x1,x2, color = y) plt.show() when I run this it shows me error code of Trace...

 
10:52 AM
0
Q: Dataframe Dealing With Missing Time Series Data

Christopher TurnbullMy df is an array time series taken every minute over a period of ~60 days. 1.I want to first segment the df into 24 hour periods 2.I then want to plot certain attributes as a waterfall chart, line graphs on top of each other I'm thinking of using an iloc for loop to do this as the df rows are...

 
11:04 AM
0
Q: Brighten a color in matplotlib

DmanIs there anyway to make a color a lot brighter in matplotlib? I have the following color map: cmap = clr.LinearSegmentedColormap.from_list('custom blue', [(0,'#00001a'), (0.59,'#e60000'), ...

0
Q: applying the same operation to different dataframes

entercaspacouldnt find anything about this is python... ive been working on three different datasets for some machine learning projects and it has been a bit of an arduous task typing out the same commands in exactly the same way for the same operation on a different data frame... it started with this: a...

 
 
1 hour later…
12:13 PM
0
Q: Pandas and numpy dimensions for multiplication

A1122I have a dataset x as 26.398016 1.0 26.444540 1.0 26.374846 1.0 26.325744 1.0 26.172441 1.0 26.345643 1.0 26.335722 1.0 26.291595 1.0 26.298693 1.0 26.133619 1.0 which has shape (10,2). I have the following code for matrix multiplication within a loop: import numpy as np ...

 
12:36 PM
0
Q: To detect words in a Pandas dataframe based on the columns and reorganise them into a new format

user3655574I am trying to go through rows of sentences in a pandas dataframe and detect if certain words exist in the rows and add them to a new format accordingly. These certain words are based on the column names I have currently. Please see the attached for details. If these words exist in the specific ...

0
Q: Count if another column values

Nelson GomesI'm trying to work with Python Pandas. I have a csv file that I open and it has some columns on it. It has two columns: fruits values bananas 2 apples 5 oranges 4 pineapples 2 Using Pandas, I would like to sum the column B (values), if column A (fruits) has "apples" on ...

 
1:20 PM
0
Q: How to efficiently multiply an NumPy array of views with corresponding weights?

DelganI am facing a memory and speed problem using NumPy but my issue is quite simple. A is a large NumPy array of H * W integers. V is a list containing N views of the large array A, each view as the same (Hv, Wv) shape. K is another list containing N float weights corresponding to the views. Hv a...

0
Q: Python: single colon vs double colon

NikWhat is the difference between single and double colon in this situation? data[0:,4] vs data[0::,4] women_only_stats = data[0::,4] == "female" men_only_stats = data[0::,4] != "female" I tried to replace data[0::,4] with data[0:,4] and I see no difference. Is there any difference in this ...

 
stackoverflow.com/questions/38159793/… OP has not provided any clues of what he has done and in the comments, he seems very aggressive...
 
2:24 PM
1
Q: How do I efficiently map only those points that fall within the bounding box of a map?

Dervin ThunkI have the following code, where mp is a Shapely Multipolygon off of a Fiona box: ax = fig.add_subplot(111) minx, miny, maxx, maxy = mp.bounds w, h = maxx - minx, maxy - miny ax.set_xlim(minx, maxx) ax.set_ylim(miny, maxy) ax.set_aspect(1) patches = [] for idx, p in enumerate(mp): patches.ap...

0
Q: matplotlib: How to combine multiple bars with lines

matthaeusI have a very simple grouped-bar chart with 5 groups of 4 bars each. I used the example from the matplotlib documentation, which goes like this: import numpy as np import matplotlib.pyplot as plt ind = np.arange(5) avg_bar1 = (81191,79318,57965,60557,14793) avg_bar2 = (26826,26615,31364,31088,5...

 
2:53 PM
0
Q: How to make columns in dataframe to be unique?

RocketqI wanted to apply one-hot encoding(it doesn't important to understand the question) to my dataframe this way: train = pd.concat([train, pd.get_dummies(train['Canal_ID'])], axis=1, join_axes=[train.index]) train.drop([11,'Canal_ID'],axis=1, inplace = True) train = pd.concat([train, pd.get_dummie...

 
3:13 PM
0
Q: Python Pandas: How do I give the opposite duplicated value

nicmanoIยดm doing some resarch on a dataframe for people that are relative. But I canยดt manage when I find brothers, I canยดt find a way to write them down all on a specific column. Here follow an example: cols = ['Name','Father','Brother'] df = pd.DataFrame({'Brother':'', 'Father':['E...

 
3:24 PM
0
Q: find the start position of the longest sequence of 1's

MASI want to find the start position of the longest sequence of 1's in my array: a1=[0,0,1,1,1,1,0,0,1,1] #2 I am following this answer to find the length of the longest sequence. However, I was not able to determine the position.

 
3:53 PM
0
Q: Points that follow a 1/R density distribution in an XY grid?

AmruthAlfredI have a XY grid with some gridpoints having certain values assigned to them, in this case, each value means a certain mass, so basically point masses in a grid. I now want to obtain a set of points which follow a density distribution of 1/R, where R is the distance from the center, so R = sqrt(x...

 
4:42 PM
0
Q: Pandas: Series of quotients of adjacent elements

KodiologistFor a Series x, x.diff() creates a new Series y with y[0] == NaN, y[1] == x[1] - x[0], y[2] == x[2] - x[1], etc. Suppose I want the equivalent with division rather than subtraction, such that y[1] == x[1] / x[0], etc. What's a good way to compute that?

 
4:57 PM
0
Q: Tkinter: passing values from one page/frame to another

Linh PhanSo I'm trying to have matplotlib working with tkinter, which is why I adopted the model from https://pythonprogramming.net/how-to-embed-matplotlib-graph-tkinter-gui/. However, instead of plotting with known values as in the example, I would need the values from one frame to do calculation/plottin...

 
5:11 PM
0
Q: pyinstall error pyi_rth_qt5

yuweiI am build a python program by using pyqt5 and matplotlib. it is work. and I use the pyinstaller to build a executable file. it is work on my win10 and other win10. but when the win7 open it, it will have error said failed to executable script pyi_rth_qt5. I do not know what is wrong? can someone...

0
Q: why dropna() is not working as I expect it to?

Al_IskanderI have asked this question already once but deleted it because it did not address the issue in the correct way. I want to drop all rows that contain NaN. I am quite sure I would need to apply df.dropna(how='all', inplace=True) to achieve what I need. But for some unknown reason it simply doe...

 
6:01 PM
0
Q: Create a list of column names

Jake StokesI'm trying to create a columns variable containing a list of all the column titles in a dataframe called london I tried using london.columns but this result gives me a list contained within: Index(the list, dtype='object') I'm currently using: columns = [] for i in range(len(london.column...

1
Q: ValueError: operands could not be broadcast together with shapes (200,49000) (10,49000) (200,49000)

muglikara=np.zeros((20,4900)) b=np.zeros((1,4900)) a+=b works perfectly fine. However, this: a=np.zeros((200,4900)) b=np.zeros((10,49000)) a+=b shows this error: ValueError: operands could not be broadcast together with shapes (200,49000) (10,49000) (200,49000) What might be the reason for th...

0
Q: How to write my code efficiently, to scale for large datsets

trinadh guptaMy sample data line looks like this u--19::m--La vita รจ bella::t--bittersweet::t--holocaust::t--World War II::d--Roberto Benigni::a--Roberto Benigni::a--Nicoletta Braschi::a--Giorgio Cantarini and I am building a dictionary for each keyword split by '::' and all the words associated with it. d...

 
6:21 PM
-3
Q: How can read_csv determine the last modified file in a directory?

TannerI have a directory where a daily report is placed. When I want to run my script, I want to read into the .csv that was last placed in the directory (regardless of that days date)

0
Q: dataframe index not equal to its copy

piRSquaredI've been down a long rabbit hole trying to reproduce a problem I'm seeing with a dataframe of length approximately 3.5 million. The question boils down to: Question Can someone produce an example of this happening: df.index.is_unique True And df.index.copy().is_unique False I didn't t...

 
6:32 PM
0
Q: Creating logical array from numpy array

JmattI have a very large numpy array in Python full of meteorological data. In order to observe flawed data, I would like to look at every value and test it to see if it is less than -1. Eventually I would like to represent this with a logical array of 0's and 1's with 1 representing indices where the...

0
Q: Python: scatter plot: How to plot frequency of one event with respect to other?

TarunI want to use python/matplotlib/pandas for my purpose. Problem description: I have an excel sheet (which I can read as a pandas dataframe) containing a table of true and estimated values. I want to somehow capture this information over a plot of actual (horizontal axis) vs estimated values (vert...

-1
Q: Python : Split list in a specific way?

RangooskiLet's say I have a list A = [1,2,3,4,5,6,7,8,9,10] I want to split them like below? A = [[1,2,3], [3,4,5], [5,6,7], [7,8,9], [9,10,0] ] I believe there a function in numpy array for such kind of operation. Any suggestion will be helpful.

 
7:02 PM
0
Q: How does this OR if conditionals evaluate (python)

KevinI'm doing some custom reporting for a client of ours. I currently read in a csv and perform a number of operations to reduce the manual work on their end. I have this line of python code: def review(row): if (1-(row['COST']/row['Competitor Price']) < .2) or row['NUM_SELL_THRU_PCT'] > 50 or...

 
7:14 PM
0
Q: How to combine two pandas DataFrames in a "horizontal union" with python3

nteissI have to large .csv files that I'm handling with python, pandas and numpy, here is a sample from the more granular data set (A), the time stamps are in 15 minute intervals: Timestamp,Real Energy Into the Load 2016-06-01T11:00:00, 2 2016-06-01T10:45:00, 1 2016-06-01T10:30:00, 5 2016-06-01T10:15:...

 
7:37 PM
0
Q: Pandas/numpy help vectorizing sequence of lookup, calculation and reordering across dataframes

kip6000I'm trying to process data from three (csv) files say p, c, f: In p, each row has labels In c, each row has scores for labels in corresponding row in p (p is matched to c) In f, each row is a label and another score For e.g., loaded into df_p, df_c and df_f respectively: >>> df_p p1 ...

 
7:49 PM
0
Q: How does the ".pop()" function of sets work in python?

Shadow_SphynxI was working in a code with remove(), discard() and pop() functions. The definition of pop() function is that: removes an arbitrary element from the set But in this code of mine: temp = raw_input() input_set = set(raw_input().split()) size = int(raw_input()) input_command = list() sum = 0 for...

 
8:23 PM
0
Q: How to plot histogram bars when the distribtuion is already given?

theQmanI want something similar to plt.hist(x), but in my case I don't have a dataset, but the underlying discrete probability distribution. For example, p = [0.1, 0.1, 0.1, 0.7], and I would like a plot with 4 bars, the fourth being the largest. If I just do plt.plot(p), the graph is interpolated, and ...

 
8:44 PM
0
Q: mathplotlib contour goes wrong, why?

kernashI have exactly the same question as create heatmap2d from txt file. My 2D-Map has different dimensions though: gnuplot diagram When I run the python script for matplotlib, the range is limited: mathplotlib contour I went through the script several times, but I don't understand why. Help?

0
Q: Getting Unusual error with Pandas for a regression learning program in python

Lucky Ansariimport pandas as pandas import Quandl as Quandl df = Quandl.get('WIKI/GOOGL') print (df.head) when i try to run this program it generates an unusual error Traceback (most recent call last): File "/home/machine/.local/lib/python3.5/site-packages/pandas/init.py", line 25, in from panda...

 
9:05 PM
1
Q: Dividing Pandas Dataframe by Week

RSHAPI have a dataframe with columns "Date" and "Num". dates = pd.date_range('1/1/2001','1/1/2003', freq = 'd') nums = [np.random.randint(100) for x in range(len(dates))] df = pd.DataFrame({'Dates': dates, 'DOW': dates.strftime('%a'), 'Nums': nums}) df = df[(df.DOW != 'Sat') & (df.DOW !='Sun')] df ...

 
9:20 PM
0
Q: Regex-guided crawler that downloads regex-matching images up to a crawling level

Gustavo6046This is one simple crawler that downloads images from websites, the website's URL to be crawled to must match the regex, as well as any image-to-download's URL. (Also, I know, I made my own thread pool, because I did want to keep my crawler lightweight...) Code: import BeautifulSoup import req...

 
9:37 PM
-1
Q: Why is this code not being accepted by HackerRank's Online Judge?

Shadow_SphynxThe problem details are here: Problem in HackerRank Why does this code: for i in range(1,input()): print (str(i)*i) generates Wrong Answer?

 
9:57 PM
0
Q: numpy.ma (masked) array mean method has inconsitent return type

dermenI noticed that the numpy masked-array mean method returns different types when it probably should not: import numpy as np A = np.ma.masked_equal([1,1,0], value=0) B = np.ma.masked_equal([1,1,1], value=0) # no masked values type(A.mean()) #numpy.float64 type(B.mean()) #numpy.ma.core.MaskedArray...

 
 
2 hours later…
11:53 PM
0
Q: can not import numpy,scipy,pandas,etc in python ubuntu 16

Bhishan PoudelI know this is the one of the most times asked question and there are literally infinite links in google to solve this question, however, this saturday whole I tried to solve this problem to no avial. My problem is I just installed Ubuntu 16, then installed python modules: sudo -H pip install n...

 

« first day (861 days earlier)      last day (1327 days later) »