Interesting Tags
   11 tags on

1 answer

pandas dataframe - filtering gives unexpected error 'unorderable types'

The following snippet of Python gives me an error: df = pandas.DataFrame({'A': ['UBS','UBS','ABB','UBS'], 'B': ['L', 'L', 'L', 'D']}) cols = ['A', 'A', 'B'] df = df[cols] df = ...

1 answers | 58 secs ago by Anne on Stack Overflow stackoverflow.com
0 answers

Python multiprocessing error with class methods

I am writing a program where I have object oriented code where I am trying to do multiprocessing. I was getting pickle errors because by default python can serialize functions but not class methods. ...

1 answer

printing special characters without spaces

I made a for loop to write a little program that has an if condition. I want to print a number and put it between '' without any space. Here is a portion of my program : for y in range(2): ...

2 answers

Why is 'x' in ('x',) faster than 'x' == 'x'?

>>> timeit.timeit("'x' in ('x',)") 0.04869917374131205 >>> timeit.timeit("'x' == 'x'") 0.06144205736110564 Also works for multiple options, both seem to grow linearly: ...

0 answers

Replacing lines of output with custom message

I am trying to build a function that asks the user to enter a taboo word and then a filename. The script should then open the file and print it line by line, but replacing any line that has the taboo ...

0 answers

Python: Check whether list is sequential or not

Want a function / statement, to check whether all the values of mylist are sequential or not, which is hexadecimal list. For example: def checkmylist(mylist): #code returns True or False Not ...

0 answers

How to get names of first 200 Facebook users using Python?

I am trying to get the names of first 200 Facebook users. I am using Python and BeautifulSoup The approach which I'm using is that instead of using Graph API, I'm trying to get the names using the ...

0 answers

Sympy left hand side of inequality

I am using sympy to solve a simpe inequality. After solving it, I want to assign the right hand side of the solution to a new variable. from sympy.solvers.inequalities import ...

1 answer

How to I cut a wav file based on time segments?

I have a wav file that I need to split up using the following list: [0.89, 1.38, 1.945, 2.93, 3.435, 4.47, 5.435, 6.035, 6.67, 7.665, 8.48] I want to create an array of smaller wav files that are ...

1 answers | 6 mins ago by Michi on Stack Overflow stackoverflow.com
2 answers

Plotly killed my python install

I just tried to install Plotly using pip. I am running python from Anaconda and now anytime I attempt to run anything python I get the following errors and I have no idea how to fix it. I am running ...

2 answers | 6 mins ago by badrobit on Stack Overflow stackoverflow.com
0 answers

How to plug in numbers in a symbolic expression generated in Python?

I'm fairly new to Python and have used SymPy to compute compute symbolic expressions. I now want to import this file and plug in numbers to each symbol using mpmath. I'm able to import the expressions ...

0 answers

Matplotlib's matshow not aligned with grid

I have a 6x6 matrix that represents a grid. On part of that grid I have a smaller grid (3x3) represented below: In [65]: arr = np.zeros((6,6)) arr[0:3, 0:3] = 1 arr Out[65]: array([[ 1., 1., 1., ...

0 answers

python socket tcp server refuse connection

Hi there i was try to connect a client and a server using python socket... both the sides(client and server) are working without any error... Problem : When I try to connect the client to the server ...

4 answers

Python semi colon does make any difference

Why use of colon makes difference to result? And what should be the correct result. # Not stored in different location. >>> id('123 4')== id('123 4') True # also returns true >>> x ...

4 answers | 17 mins ago by Ankit Sachdeva on Stack Overflow stackoverflow.com
3 answers

passing class name as argument to function?

Here in given code it is passing class name i.e. MyRequestHandler to TCP and also after taking class name as argument what does it do with that.So my question is that can class name be used as ...

3 answers | 18 mins ago by user3398557 on Stack Overflow stackoverflow.com
0 answers

Check if chromelogger works or not in python

I've installed chromelogger for Python on my server: https://github.com/ccampbell/chromelogger-python But when I looked at the Chrome console in hope to see printed debugging information ("Hello ...

0 answers

Plotting bar plot in python

I am trying to plot a single bar plot with multiple colors... width = 0.3 y1 =[78.0] y2= [70863.0] y3 =[138441.0] y4 =[ 8223.0] x = np.range(2) p1 = plt.bar(x, y1, width=width, color='r') ...

1 answer

Specify which method to call

Consider this class: class Foo(object): def bar(self, name): return 'bar: ' + name def baz(self, name): return 'baz: ' + name I need to tell code to run the baz method: ...

1 answers | 20 mins ago by dotancohen on Stack Overflow stackoverflow.com
0 answers

Creating full screen plots in bokeh

I am using bokeh to generate several line plots which are fairly wide in nature. I have been looking but have not found any code that would allow me to initialize the plots so that they took up the ...

0 answers

How to incorporate multiprocessing into existing python code?

I am having a serious problem wrapping my head around using multiprocessing in my existing python code. Below is my program gauss.py which essentially fits a Gaussian to data. What is the correct way ...

0 answers

Reindexing after pandas.drop_duplicates

I want to open a file, read it, drop duplicates in two of the file's columns, and then further use the file without the duplicates to do some calculations. To do this I am using ...

0 answers

Sublime API missing

I try to install 'Sublime Text 3' on Fedora 21 from official site, but when I execute "sublime.py" it says: Traceback (most recent call last): File "sublime.py", line 1, in <module> ...

3 answers

What's the Perl equivalent of Python's enumerate?

I'm looking for a function in Perl 5 that works similarly to Python's enemurate built-in. It would return a list of references to arrays, where each array is [$index, $element]: @a = ("a", "b", "c"); ...

3 answers | 31 mins ago by Flimm on Stack Overflow stackoverflow.com
0 answers

Does Jython have a 'startup file' like Python?

Jython 2.7b2 does not respect PYTHONSTARTUP, nor does it respect JYTHONSTARTUP. If there is no such thing in Jython, what would be a good workaround?

1 answer

Matlab timeit equivalent in Python for scripts

In Matlab there is "timeit(F), which measures the typical time (in seconds) required to run the function specified by the function handle F that takes no input argument." This method returns ...

1 answers | 32 mins ago by mdj15 on Stack Overflow stackoverflow.com
0 answers

Is there a function in python to convert html encoding to percent encoding?

I am retrieving Japanese and Chinese text from a website in the form of JSON using urllib2 and converting them to HTML encoding using encode(xmlcharrefreplace). I then use curl to post the same ...

1 answer

Issues+Clarification: Sending message from Raspberry Pi to Android Phone using Google cloud Messaging

I am new to Raspberry Pi and Google Cloud Messaging. What I want to do is as follows: Raspberry Pi is reading some sensor data and I want to send the data to my Android Phone in real time, i.e. as ...

4 answers

Python Running cumulative sum with a given window

what I want to do is generate a numpy array that is the cumulative sum of another numpy array given a certain window. For example, given an array [1,2,3,4,5,6,7,8,9,10,11,12] lets say I want a ...

1 answer

502 Bad Gateway connecting Nginx to django via socket

I'm trying to follow the tutorial at http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html. I've gotten everything working down to ...

0 answers

bokeh turn on grid image

I just can't seem to grok plotting library documentation! I have spent ages looking at the documentation for Bokeh and I can't figure out how to turn on the grid for this example: ...

15 30 50 per page
1 2 3