Tag: python

54 votes
12 answers
2.8K views
Should I put #! (shebang) in Python scripts, and what form should it take?

Should I put the shebang in my Python scripts? In what form? #!/usr/bin/env python or #!/usr/local/bin/py

avatar
Omar
0 1 0 9
asked 07 September, 2021
64 votes
20 answers
2.6K views
Running shell command and capturing the output

I want to write a function that will execute a shell command and return its output as a string, no matter, is

avatar
Rufus
0 1 0 9
asked 07 September, 2021
52 votes
21 answers
377 views
Why do people write #!/usr/bin/env python on the first line of a Python script?

It seems to me like the files run the same without that line.

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
45 votes
27 answers
1.4K views
Pretty printing XML in Python

What is the best way (or are the various ways) to pretty print XML in Python?

avatar
Adolfo
0 1 0 9
asked 07 September, 2021
63 votes
18 answers
1.1K views
How to parse XML and count instances of a particular node attribute?

I have many rows in a database that contains XML and I'm trying to write a Python script to count instanc

avatar
Nidia
0 1 0 9
asked 07 September, 2021
50 votes
3 answers
1K views
How to implement band-pass Butterworth filter with Scipy.signal.butter

UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested, go straight to: Contents ยป

avatar
Rufus
0 1 0 9
asked 07 September, 2021
47 votes
4 answers
2.3K views
shuffle vs permute numpy

What is the difference between numpy.random.shuffle(x) and numpy.random.permutation(x)? I have read the doc p

avatar
Scot
0 1 0 9
asked 07 September, 2021
56 votes
4 answers
1.2K views
MatPlotLib: Multiple datasets on the same scatter plot

I want to plot multiple data sets on the same scatter plot: cases = scatter(x[:4], y[:4], s=10, c='b&apo

avatar
Lynette
0 1 0 9
asked 07 September, 2021
63 votes
9 answers
519 views
ImportError: cannot import name NUMPY_MKL

I am trying to run the following simple code import scipy scipy.test() But I am getting the following erro

avatar
Emilia
0 1 0 9
asked 07 September, 2021
58 votes
9 answers
2.3K views
Quantile-Quantile Plot using SciPy

How would you create a qq-plot using Python? Assuming that you have a large set of measurements and are using

avatar
Dario
0 1 0 9
asked 07 September, 2021
55 votes
2 answers
2.6K views
Two-sample Kolmogorov-Smirnov Test in Python Scipy

I can't figure out how to do a Two-sample KS test in Scipy. After reading the documentation scipy kstest

avatar
Chelsea
0 1 0 9
asked 07 September, 2021
58 votes
4 answers
2.7K views
How to transform numpy.matrix or array to scipy sparse matrix

For SciPy sparse matrix, one can use todense() or toarray() to transform to NumPy matrix or array. What are th

avatar
Patsy
0 1 0 9
asked 07 September, 2021
62 votes
13 answers
1.2K views
ImportError: No module named scipy

I am using Python 2.7 and trying to get PyBrain to work. But I get this error even though scipy is installed

avatar
Eddie
0 1 0 9
asked 07 September, 2021
69 votes
12 answers
2.1K views
scipy: savefig without frames, axes, only content

In numpy/scipy I have an image stored in an array. I can display it, I want to save it using savefig without a

avatar
Robyn
0 1 0 9
asked 07 September, 2021
63 votes
9 answers
627 views
How to calculate probability in a normal distribution given mean & standard deviation?

How to calculate probability in normal distribution given mean, std in Python? I can always explicitly code my

avatar
Forrest
0 1 0 9
asked 07 September, 2021
52 votes
7 answers
650 views
Plotting a fast Fourier transform in Python

I have access to NumPy and SciPy and want to create a simple FFT of a data set. I have two lists, one that is

avatar
Deedee
0 1 0 9
asked 07 September, 2021
65 votes
11 answers
1.5K views
Principal component analysis in Python

I'd like to use principal component analysis (PCA) for dimensionality reduction. Does numpy or scipy alr

avatar
Wei
0 1 0 9
asked 07 September, 2021
48 votes
7 answers
1K views
Histogram Matplotlib

So I have a little problem. I have a data set in scipy that is already in the histogram format, so I have the

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
55 votes
1 answers
343 views
How can I perform two-dimensional interpolation using scipy?

This Q&A is intended as a canonical(-ish) concerning two-dimensional (and multi-dimensional) interpolatio

avatar
Roger
0 1 0 9
asked 07 September, 2021
56 votes
8 answers
784 views
How to calculate cumulative normal distribution?

I am looking for a function in Numpy or Scipy (or any rigorous Python library) that will give me the cumulativ

avatar
Wei
0 1 0 9
asked 07 September, 2021