Unnamed: 0 int64 0 378k | id int64 49.9k 73.8M | title stringlengths 15 150 | question stringlengths 37 64.2k | answer stringlengths 37 44.1k | tags stringlengths 5 106 | score int64 -10 5.87k |
|---|---|---|---|---|---|---|
350,200 | 50,031,616 | Multiply each channel by different matrix? | <p>Is there a way, in tensorflow, to multiply each channel by a different matrix?</p>
<p>Imagine you have a 2D array A of dimensions (N, D1).
You can multiply it by an array B of size (D1, D2) to get output size (N, D2). </p>
<p>Now imagine you have a 3D array of dimensions (N, D1, 3).
Suppose you had B1, B2, B3 all ... | <p><a href="https://www.tensorflow.org/api_docs/python/tf/einsum" rel="nofollow noreferrer"><code>tf.einsum()</code></a> could be applied here.</p>
<p>To make the code below easier to understand, I renamed <code>D1</code> = <code>O</code> and <code>D2</code> = <code>P</code>.</p>
<pre class="lang-python prettyprint-o... | tensorflow | 2 |
350,201 | 49,925,598 | Pandas Dataframe remap categorical column with two values to binary | <p>I have a dataframe coming in and would like to check for strings of 'Male' or 'Female', and if the dataframe contained them it would be replaced with '1' or '0'. At the moment I'm using the code below thanks to <a href="https://stackoverflow.com/questions/31888871/pandas-replacing-column-values">@Anand S Kumar's ans... | <p>Going on good faith, assuming your column contains valid data, why not replace based on the <em>first letter</em> of every row?</p>
<pre><code>m = {'m' : 1, 'f' : 0}
df['gender'] = df['gender'].str[0].str.lower().map(m)
</code></pre>
<p>Using <code>map</code>, invalid entries are automatically coerced to NaN.</p> | python|pandas|dataframe|categorical-data | 6 |
350,202 | 50,040,428 | How to reshape input data for tflearn? | <p>I'm trying to reshape my data to be compatible with a tflearn, each row in my data is in the shape (1300, 13). So after I load the data and put each of these (1300, 13) shaped rows in a numpy array like this this:</p>
<pre><code>data_path = os.path.dirname(os.path.realpath(__file__)) + '/../data/data.csv'
train = d... | <p>Figured it out, had to preallocate arrays:</p>
<pre><code>train_x = np.empty((train['lowLevel.mfcc'].size, 1300, 13))
test_x = np.empty((test['lowLevel.mfcc'].size, 1300, 13))
for index, item in enumerate(train['lowLevel.mfcc']):
train_x[index] = item
for index, item in enumerate(test['lowLevel.mfcc']):
t... | python|pandas|numpy|tflearn | 1 |
350,203 | 50,006,011 | GRU switched to CuDNNGRU has error of Unknown input node | <p>Hi I am trying GRU and CuDNNGRU models at Keras. GRU model can work perfectly. But when I switched to CuDNNGRU, error indicates. Here are my codes</p>
<pre><code>def get_model():
input_words = Input((maxlen, ))
x_words = Embedding(max_features, 300,
weights=[embedding_matrix],
... | <p>I had it before, it's because that you didn't configure the Cudnn ..</p> | python-3.x|tensorflow|recurrent-neural-network|keras-layer | 0 |
350,204 | 50,017,241 | Converting grayscale to RGB in tfrecord | <p>I have a dataset of grayscale images, and I'd like to use the sdd-mobilenet checkpoints for training my object detection.
What is the proper way to convert grayscale images to RGB that I can convert my dataset to tfrecord?
Here is the code that I use (notice that the commented parts didn't work for me)</p>
<pre><co... | <p>I tried different methods and finally could get an answer (not only converting to tfrecords, but also the training and the object detection itself).</p>
<p>If the dataset only consists of grayscale images, Tensorflow object detection only needs the number of channels to be defined as 3. Therefore, <strong>the only ... | python|tensorflow|object-detection|tfrecord | 3 |
350,205 | 49,911,682 | Installing Tensorflow for Keras: cloud-init missing parts | <p><strong>Setup</strong>: This is all done using an Amazon Web Services EC2 instance.</p>
<ol>
<li>Amazon Linux AMI 2017.09.1 (HVM), SSD Volume Type </li>
<li>RStudio Server</li>
</ol>
<p><strong>What I've tried</strong>: I am trying to install the <code>keras</code> package in <code>R</code> with <code>tensorflow</... | <p>I had the same problem,
try 'sudo pip install (what's missing,ex:argparse)'</p>
<p>Worked for me, hope this helps :)</p> | r|amazon-web-services|tensorflow|keras | 4 |
350,206 | 49,810,393 | Parameterizing mixture density network covariances in tensorflow | <p>I'm trying to build an MDN to learn P(y | x) where both y and x have dimension D, with K components with full (non-diagonal) covariances. From the output of the hidden layers of the NN I need to construct the component means, weights and covariances. For the covariances, I want a set of lower triangular matrices (i.... | <h3>TL;DR: use <a href="https://www.tensorflow.org/api_docs/python/tf/contrib/distributions/fill_triangular" rel="nofollow noreferrer">tf.contrib.distributions.fill_triangular</a></h3>
<hr>
<p>Assuming that X is a tensor of <code>K</code> elements of <code>D</code> dimensions, let's define it as a <a href="https://ww... | python|tensorflow|mixture-model | 3 |
350,207 | 50,159,125 | loss stops decreasing during training a MLP network | <p>I build a MLP based on 1D convolution for prediction purposes, the model architecture looks as follows. However, the training process of this model tends to stop after only two epochs. The training process statistics is shown as follows, what might be the reason and how to modify it? The code is this</p>
<pre><cod... | <p>I think you are using default learning rate of <code>0.01</code>, with my past experience with Keras I can say that you might have to reduce the learning rate, maybe to <code>0.001</code> or <code>0.0001</code></p>
<p>You can find the default values in this function signature: <a href="https://keras.io/optimizers/#... | tensorflow|deep-learning|keras | 0 |
350,208 | 50,128,934 | Pandas dict keys to columns | <p>I have a dataframe like this. </p>
<pre><code>index column1
e1 {u'c680': 5, u'c681': 1, u'c682': 2, u'c57...
e2 {u'c680': 6, u'c681': 2, u'c682': 1, u'c57...
e3 {u'c680': 2, u'c681': 4, u'c682': 2, u'c57...
e4 {u'c680': 4, u'c681': 2, u'c682': 3, u'c57...
e5 ... | <p>The best here is not use <code>apply(pd.Series)</code> because very slow, but <code>DataFrame</code> contructor with convert <code>NaN</code>s to <code>0</code> and then to <code>int</code>s:</p>
<pre><code>df = pd.DataFrame({'column1': [{'c681': 1, 'c682': 2, 'c57': 4, 'c680': 5},
{... | python|pandas | 4 |
350,209 | 50,119,597 | Pandas - Filter DF to contain only rows in which each column is FALSE | <p>I have a dataframe which contains only boolean values. I would like to split this into two dataframes; the first containing rows in which every column's value is False, and the second containing rows in which 1 or more column's value is True.</p>
<p>I know this is a very solvable problem in pandas just having troub... | <pre><code>df[-df.any(axis=1)] # All Falses; not any one is True
df[ df.any(axis=1)] # Not all Falses
</code></pre> | python|pandas|dataframe | 2 |
350,210 | 49,978,909 | Calculating Autocorrelation (ACF) : coercing to Unicode: need string or buffer, float found | <p>I want to use Autocorrelation plots from pandas.plotting in order to check randomness in time series. My dataframe looks like this :</p>
<pre><code> DATE reqUser sum_event_count
0 2017-10-08 21:00:00 bddfdpadm 92542.0
1 2017-10-11 06:00:00 bscdpadm 1913.0
2 2017-10-11 11:00:00 ambar... | <p>I think need pass <code>Series</code> as commented <a href="https://stackoverflow.com/questions/49978909/calculating-autocorrelation-acf-coercing-to-unicode-need-string-or-buffer/49979094#comment86973856_49978909">ayhan</a>.</p>
<p><a href="https://pandas.pydata.org/pandas-docs/stable/visualization.html#visualizati... | pandas|matplotlib|math|time-series|correlation | 1 |
350,211 | 50,018,595 | python code for mathematics graph | <p>wrote some Python code to plot the coordinates of simple one dimensional linear mapping using matplotlib. </p>
<p>There is no warnings and errors, but no coordinates are entered in graph. </p>
<p>Can someone tell me what's wrong with my code?</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
resu... | <p>length of result is 1, hence the loop doesn't run at all.</p>
<p>Perhaps you wanted to do</p>
<pre><code>result = [0 for i in range(11)]
</code></pre>
<p>or </p>
<pre><code>result = np.zeros(11)
</code></pre>
<p>when you initiate result.</p>
<p>(Credit: abukaj for suggesting using np.zeros)</p>
<p>Edit:</p>
... | python|numpy|matplotlib | 3 |
350,212 | 49,953,379 | Tensorflow: Multiple loss functions vs Multiple training ops | <p>I am creating a Tensorflow model which predicts multiple outputs (with different activations). I think there are two ways to do this:</p>
<p><strong>Method 1:</strong> Create multiple loss functions (one for each output), merge them (using <code>tf.reduce_mean</code> or <code>tf.reduce_sum</code>) and pass it to th... | <p>I want to make a subtle point that I don't think was made in previous answers.</p>
<p>If you were using something like GradientDescentOptimizer, these would be very similar operations. That's because taking gradients is a linear operation, and the gradient of a sum is the same as the sum of the gradients.</p>
<p>B... | python|tensorflow | 25 |
350,213 | 50,134,054 | Unhashable type "slice" when trying to plot Random Forest | <p>I am trying to plot my Random Forest, but it gives me the following error: TypeError: unhashable type: 'slice' in addition to displaying empty plots. The model itself works fine, giving me acceptable precision and recall scores.</p>
<pre><code>from sklearn.ensemble import RandomForestClassifier
forest = RandomFores... | <p>The error comes from pandas because the function doesn't support it</p>
<p>Try replacing your dataframe <code>train_x</code> with <code>train_x.values</code> in your <code>plot_2d_separator</code></p>
<p>Hope this helps,<br>
Cheers</p> | python|pandas|matplotlib|scikit-learn|random-forest | 0 |
350,214 | 50,187,082 | How to extract the Word from Rows in Pandas DataFrame | <p>If I have column name category and in that I have rows like Plane Travel|Train Travel|Bus Travel then how can I extract Plane Travel in pandas Dataframe</p> | <p>You need to use the <code>.str</code> accessor and then <code>.split()</code> your string then you can put the result into separated columns.</p>
<p>Let's generate the proper DataFrame:</p>
<pre><code>df = pd.DataFrame({"Category":["Plane France", "Train Russia", "Spacecraft Moon"],
"other_varia... | pandas | 0 |
350,215 | 50,123,534 | Why does norm.pdf of evenly spaced values give a normal distribution? | <p>Can anyone please explain what goes behind the scenes of a norm.pdf function in python?<br>
I saw a uniform distribution (formed using <code>x = np.arange(-3, 3, 0.001)</code>) being used to plot a normal distribution using <code>plt.plot(x, norm.pdf(x))</code>. So how does norm.pdf convert uniformly distributed val... | <p><code>pdf</code> is short for 'Probability Density Function', it represents the density of a random distribution for a given value; that is, how likely is that distribution to output that value? This is the most commonly plotted chart for most distributions, since peaks (on the y axis) represent commonly output valu... | python|numpy|matplotlib|scipy|normal-distribution | 0 |
350,216 | 50,212,021 | Numpy error with python 2.7.12 | <p>I have both python2.7 and python3.5 installed on Ubuntu 16.04. After I write import numpy in python2.7 environment, I get the following error,</p>
<pre><code>Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>... | <p>you are importing a version of Numpy who are for python 3.5</p>
<p>you must download the version who are for 2.7
you can find the download packages of numpy as : <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy" rel="nofollow noreferrer">http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy</a></p> | python-2.7|numpy|importerror | 0 |
350,217 | 49,944,388 | indexing interval data with pandas | <p>I want to select the values of a variable in a pandas dataframe above a certain percentile. I have tried using binned data with pd.cut, but the result of cut is a pandas interval (I think unordered) and I don't know how to select values</p>
<pre><code>df = pd.DataFrame(np.random.randint(0,100,size=150), columns=['w... | <p>You don't need bins, <code>Pandas</code> already have <a href="http://Quantile%20function%20pandas" rel="nofollow noreferrer">quantile</a> function.</p>
<pre><code>df[df.whatever > df.whatever.quantile(0.95)]
</code></pre> | python-3.x|pandas|categorical-data | 0 |
350,218 | 50,140,866 | Python: Dictionary that will pull data from every row | <p>I'm trying to create a dictionary that will give me the values for each state that I plug into the key value. Here's my code:</p>
<p><code>sat_partic = {'State': 'Participation'}</code></p>
<p>but this just gives me the variables i inputted in the curly brackets. </p>
<p>I appreciate your help and suggestions. </... | <p>The complete answer:</p>
<pre><code>d = df.set_index('State')['Participation'].to_dict()
</code></pre>
<p>However, in many situations this is not necessary, since you can use <code>pd.Series.get</code> with similar functionality.</p>
<p>For example, you can use:</p>
<pre><code>d = df.set_index('State')['Particip... | python|pandas|dictionary | 2 |
350,219 | 50,078,515 | IndexError: tuple index out of range using Partial Correlation function | <p>I'm using the partial correlation function developed by Fabian Pedregosa-Izquierdo (a MatLab copy of parrcor).</p>
<p>However, I'm trying to apply it to my data I keep getting the following error:</p>
<pre><code> Traceback (most recent call last):
File "atd.py", line 280, in <module>
partialcorr = partial_co... | <p>The function you posted expects to receive an <code>n x m</code> matrix as an argument. You are passing it an array of length <code>n</code>. To get your data into the right shape, you can do something like:</p>
<pre><code>my_data = [1.234, 5.6789, -32.101]
C = np.array(my_data).reshape((-1,1))
partial_corr(C)
</c... | arrays|python-3.x|numpy|scipy|tuples | 1 |
350,220 | 49,810,144 | How to get data on an hourly basis | <p>I have a csv file whose content is below</p>
<pre><code>2018-02-28 09:48:18.884392+05:30,,
2018-03-04 10:50:34.833787+05:30,,
2018-03-05 13:04:23.634013+05:30,,
2018-03-14 05:30:14.51227+05:30,28.84,27.58
2018-03-14 05:45:14.51227+05:30,12.54,17.47
2018-03-14 06:30:14.466206+05:30,25.1,23.58
2018-03-14 06:40:14.466... | <p>IIUC you are using <code>last()</code> which gives last value instead use <code>mean()</code>:</p>
<pre><code>df.resample('H').mean().fillna(0)
</code></pre> | python-3.x|pandas | 1 |
350,221 | 49,962,533 | I need to Un-nest JSON array elements AND ensure correct mapping with 'ID' column | <p>The input DataFrame "df" which is as follows (Please take note of values in 'id' column):</p>
<pre><code>| id | name |
|-------|---------------------------------------------------------------------------------------|
| a1xy | [ { ... | <p>You can use list comprehension with flattening and update each dictionary by <code>id</code> values, last call <code>DataFrame</code> contructor:</p>
<pre><code>df['name'] = df['name'].map(json.loads)
df = pd.DataFrame([dict(y, id=i) for i, x in zip(df['id'],df['name']) for y in x])
print (df)
event id star... | python|arrays|json|pandas | 1 |
350,222 | 50,144,283 | Python: Mapping between two arrays with an index array | <p>I have a numpy array </p>
<pre><code>src = np.random.rand(320,240)
</code></pre>
<p>and another numpy array <code>idx</code> of size (2 x (320*240)). Each column of <code>idx</code> indexes an entry in a result array <code>dst</code>, e.g., <code>idx[:,20] = [3,10]</code> references row 3, column 10 in <code>dst</... | <p>Here is the canonical way of doing it:</p>
<pre><code>>>> import numpy as np
>>>
>>> src = np.random.rand(4, 3)
>>> src
array([[0.0309325 , 0.72261479, 0.98373595],
[0.06357406, 0.44763809, 0.45116039],
[0.63992938, 0.6445605 , 0.01267776],
[0.76084312, 0.61... | python|numpy | 3 |
350,223 | 50,026,420 | tensorflow new API: TensorRT create_inference_graph error | <p>I have a self defined Faster R-CNN network for object detection, in which I define some self-defined operators: <code>nms</code> and <code>roi_pooling</code> which is compiled to <code>.so</code> file. The <code>.so</code> file is wrapped which can be called by tensorflow framework.</p>
<p>After I convert tensorflo... | <p>This is probably due to TensorRT requiring sizes of all tensors being known when it's called upon to optimize the graph. One possible fix could be specifying a fixed input image tensor size for your faster rcnn model by, say, making the following modification to the model config file.</p>
<p>Originally:</p>
<pre>... | tensorflow|tensorrt | 0 |
350,224 | 50,103,656 | How to vectorize this for loop? | <p>I have a numpy array <strong>f</strong> with length <em>n</em> and a numpy matrix <strong>A</strong> with size <em>n</em> x <em>m</em>. I want to break <strong>f</strong> and <strong>A</strong> in <em>r</em> pieces <strong>f1</strong>,...,<strong>fr</strong> and <strong>A1</strong>,...,<strong>Ar</strong>, then make... | <p>You can use <code>np.add.reduceat</code>:</p>
<pre><code># example data
>>> f = np.arange(10)
>>> A = np.arange(50).reshape(10, 5)
>>> split = [0, 3, 5, 10]
>>>
# reduceat
>>> np.add.reduceat(f[:, None] * A, split[:-1], axis=0)
array([[ 25, 28, 31, 34, 37],
... | python|numpy|for-loop|matrix | 1 |
350,225 | 49,895,000 | Regression by group in python pandas | <p>I want to ask a quick question related to regression analysis in python pandas.
So, assume that I have the following datasets:</p>
<pre><code> Group Y X
1 10 6
1 5 4
1 3 1
2 4 6
2 2 4
2 3 9
</code></pre>... | <p>I am not sure about the type of regression you need, but this is how you do an OLS (Ordinary least squares): </p>
<pre><code>import pandas as pd
import statsmodels.api as sm
def regress(data, yvar, xvars):
Y = data[yvar]
X = data[xvars]
X['intercept'] = 1.
result = sm.OLS(Y, X).fit()
return re... | python|python-3.x|python-2.7|pandas|pandas-groupby | 13 |
350,226 | 49,902,322 | convert rgb image from numpy array to HSV (opencv) | <p>When I'm converting an image from RGB to HSV, if the image come straight from opencv, everything is alright:</p>
<pre><code>img = cv2.imread(path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
</code></pre>
<p>However, if this image come from a numpy array of shape (nb_of_images, 224, 224, 3) there is some complicati... | <p>The problem is with the datatype of the elements in <code>images</code>. Right now it's <code>np.float64</code>.</p>
<p>Let's look at the assert in the <a href="https://github.com/opencv/opencv/blob/3.4.0/modules/imgproc/src/color.cpp#L11073" rel="nofollow noreferrer">C++ source code</a></p>
<pre><code>CV_Assert( ... | python|numpy|opencv | 1 |
350,227 | 49,825,205 | How to change a special character in a csv file before uploading into a dataframe in python with pandas | <p>So I have a large data set where the strings are surrounded with " symbols but in some cases they have been replaced with ” symbols, the issue with that is, it's causing pandas to think my separators are part of the elements therefore joining to elements together.</p>
<p>I'm hoping to find a way to replace the ” sy... | <p><code>str.replace</code> returns the updated string. You should wrap that in a <code>StringIO</code> and then pass it to <code>pandas</code>. Your code appears to be python 2, but python 3 is much better at unicode issues. Here is a python 3 solution that works on the example data set:</p>
<pre><code>import pandas ... | python|pandas|csv | 1 |
350,228 | 63,975,409 | Plotting a piecewise function in python with numpy | <p><strong>Note: This is for homework so please don't post full code responses, just help on what I'm misusing would be appreciated</strong></p>
<p>I'm trying to plot a piecewise defined function where when 0 < x <= 10 it will be a constant (KQ/10) and for x > 10 it will be KQ/x for 10 < x < 50. Currentl... | <p><code>x = np.linspace(0, 50, 1)</code></p>
<p>isnt how linspace works... this only creates one data point ...</p>
<p><code>x = np.linspace(0, 50, 10000)</code> ... would create 10k datapoints</p>
<p>perhaps you wanted <code>np.arange(0,50,1)</code> ?</p> | python|numpy | 2 |
350,229 | 64,153,805 | Assign a string in a column if the corresponding row of another column contains a certain substring, else another string | <p>I have a pandas dataframe like this</p>
<pre><code>index | Creative Size | Business Model
1 | Something trueview |
2 | truviewhello |
3 | dunno |
4 | str |
5 | str |
</code></pre>
<p>I want to write a code that if there is 'trueview' in ... | <p>Use <a href="https://numpy.org/doc/stable/reference/generated/numpy.where.html" rel="nofollow noreferrer"><code>numpy.where</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.contains.html" rel="nofollow noreferrer"><code>Series.str.contains</code></a>:</p>
<pre><cod... | python-3.x|pandas|dataframe | 1 |
350,230 | 64,148,255 | Split a column of string then group by the index and then add them up? | <p>so here is what I have in my dataframe</p>
<pre><code>+--------+------------------+---------------------+--+
| Userid | Country | food | |
+--------+------------------+---------------------+--+
| 1001 | United States | cheese;burger;pizza | |
| 1002 | United States | burger;pizza ... | <p>Try this using the <code>.str</code>, string accessor, and <code>get_dummies</code>, then <code>groupby</code> 'Country' column and <code>sum</code>:</p>
<pre><code>df['food'].str.get_dummies(';').groupby(df['Country']).sum()
</code></pre>
<p>Output:</p>
<pre><code> burger cheese noodles pizza
Count... | python|pandas | 1 |
350,231 | 63,884,639 | How to drop a row with the latest date plus multiple other conditions? | <p>I have the following dataframe:</p>
<pre><code>+-----+------------+----------+
| id_ | date | existing |
+-----+------------+----------+
| 1 | 01/01/2020 | Y |
| 2 | 02/01/2020 | Y |
| 3 | 02/01/2020 | N |
| 4 | 03/01/2020 | Y |
| 5 | 03/01/2020 | N |
| 6 | 03/01/... | <p>First you better sort:</p>
<pre><code>df = df.sort_values(by=['date'], ascending = True)
</code></pre>
<p>Then you need to delete the last row:</p>
<pre><code>df = df.drop(df[df['existing']=='N'].tail(1).index)
</code></pre> | python|pandas | 1 |
350,232 | 63,920,007 | How to efficiently iterate through selected Excel sheets in Python and append them into a Data Frame? | <p>Instead of manually inputing Excel sheets parameters as follows:</p>
<pre><code>import pandas as pd
df1 = pd.read_excel(r"C:\Users\XY\Sales2020.xlsm",
sheet_name = "Europe",usecols=[1,2,4,6],header=4) #reads sheet "Europe", selected columns and skips first 4 r... | <p>No need to create a new dataframe when dataset is already a dataframe.</p>
<pre><code>import pandas as pd
sheets=["Europe","North America"]
df_list=[]
for i in sheets:
dataset = pd.read_excel(r"C:\Users\XY\Sales2020.xlsm",
sheet_name = i,usecols=[1,2,4,6],heade... | python|pandas|dataframe|concat | 3 |
350,233 | 64,044,307 | error while using function with pandas series in python | <p>as input there is an array with numbers from 1 to 12. At the output, I want to get an array that will produce, depending on the number, the time of year</p>
<pre><code>import pandas as pd
month = pd.Series([i for i in range(1,13)])
def mkseason(n):
if 3<=n<=5: season = 'spring'
elif 6<=n<=8: sea... | <p>Use modulo with <code>12</code> and integer division for groups and last map by <code>dictionary</code>:</p>
<pre><code>month = (((month % 12) // 3).map({0:'winter',1:'spring',2:'summer',3:'fall'})
.fillna('unknown'))
print (month)
0 winter
1 winter
2 spring
3 spring
4 ... | python|pandas|dataframe|series | 1 |
350,234 | 64,118,038 | Creating a DataFrame in a For Loop Produces Nan Error | <p>While exploring the Olympics dataset on Jupyter Notebook, I was trying to find out which sport is the oldest from <a href="https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results" rel="nofollow noreferrer">this dataset</a>.</p>
<p><a href="https://i.stack.imgur.com/KJCPB.png" rel="nofollow ... | <p>Gosh, I can see why that was hard to debug. What's missing from your output screenshot is the last part</p>
<pre><code>Year 80
dtype: int64
Year 52
dtype: int64
...
Year 12
dtype: int64
Year 0
dtype: int64
0
</code></pre>
<p>Notice how the last line doesn't follow the pattern of the rest! If you inspect ... | python|pandas|indexing|jupyter-notebook | 2 |
350,235 | 64,091,029 | Error when Loading a .pb Tensorflow Model | <p>I created a tensorflow model on a Windows 10 machine and saved it using:</p>
<pre><code>model.save('myfolder')
</code></pre>
<p>Inside the folder <code>myfolder</code> I get:</p>
<pre><code>- saved_model.pb
- Variables folder
- Assets folder
</code></pre>
<p>Now I'm trying to load the model in a Linux machine, so I'... | <p>I just solved the same problem.</p>
<p>Check the version of Tensorflow that you are using to train and save your model and the version that you are using to load it. They must be the same or, at least, <a href="https://www.tensorflow.org/guide/versions" rel="nofollow noreferrer">compatible versions</a>.</p> | python|tensorflow|keras|tf.keras | 1 |
350,236 | 63,849,660 | How to plot bar stack in Pandas? | <p>The objective is to plot a bar that stack as shown below using the Pandas builtin plot module</p>
<p><a href="https://i.stack.imgur.com/K5DQ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K5DQ1.png" alt="Expected Output" /></a></p>
<p>However, I cannot find any near example that tried to achieve... | <p>Let's try:</p>
<pre><code>fig, ax = plt.subplots(figsize=(10,6))
hatches = ['', '//']
bar_width = 0.45
names =set(df['name'])
for i, col in enumerate(['year','reports']):
width = bar_width if i==0 else - bar_width
s = pd.crosstab(df['name'], df[col])
s.plot.bar(width=width, align='edge', stacked=True, ... | python|pandas|plot | 4 |
350,237 | 64,148,508 | Renaming pandas columns by slicing, causing merge to fail | <p>I've got two data frames that represent similar data but I want to merge after changing the col names. There are a few ways to achieve this but given the size of my actual data frames, I'd like to use the following method. I'm returning nan values for the second df.</p>
<pre><code>import pandas as pd
df1 = pd.DataF... | <ul>
<li>The issue is slice assignment of the column names.
<ul>
<li><code>df1.columns.values[1:4] = new values</code></li>
<li>Fails in pandas 1.1.1 and 1.1.2</li>
<li>Works in 1.0.1 and 1.0.5</li>
</ul>
</li>
<li><code>'time'</code> is set as the index, then reset, after changing the column names in a list-comprehens... | python|pandas|merge | 5 |
350,238 | 63,919,438 | TensorFlow keras model fit() parameters steps_per_epoch and epochs behavior on train set | <p>I'm using a tf.data dataset containing my training data consisting of (lets say) 100k images.
I'm also using a tf.data dataset containing my validation set.
Since an epoch of all 100k images takes quite long (in my case approximately one hour) before I get any feedback on performance on the validation set, I set the... | <blockquote>
<p>Is it correct to use these parameters in order to get more frequent
feedback on performance?</p>
</blockquote>
<p>Yes, it is correct to use these parameters. Here is the code that i used to fit the model.</p>
<pre><code>model.fit(
train_data,
steps_per_epoch = train_samples//batch_size,
epochs = epochs,... | python|python-3.x|tensorflow|tensorflow2.0|tensorflow-datasets | 4 |
350,239 | 64,079,790 | Add a cloumn of a Dataframe to another dataframe when there is a specific match | <p>I have a Dataframe called <code>df1</code> that is as follows:</p>
<pre><code>import pandas as pd
id_1 = [1,2,3,4,5,6,7]
df_1 = pd.DataFrame(zip(id_1, data_1), columns =['id', 'data'])
</code></pre>
<p><a href="https://i.stack.imgur.com/cSIfG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cSIfG.... | <p>Use <code>map</code> with <code>dictionary</code>:</p>
<pre><code>dd = {k:v for k, v in zip(df_1['id'], df_1['data'])}
df_2['data'] = df_2['id'].map(dd)
df_2
</code></pre>
<p>Output:</p>
<pre><code> id data
0 1 0.1
1 3 0.3
2 5 0.5
3 7 0.7
</code></pre>
<p>Timings:</p>
<p><a href="https://i.stack.i... | python|pandas | 3 |
350,240 | 63,955,343 | ColumnTransformer Passthrough not working | <p>I wanted to standardize the values in my pandas dataframe, and keep one column of values the same so I used <code>ColumnTransformer</code>. However, it seems like the function isn't passing over the column I want it to pass over. <code>df</code> is my dataframe, here's the code:</p>
<pre><code>import pandas as pd
fr... | <p>This happens because you first modificate column list and then apply column transformer. You can check</p>
<pre><code>test = ['column1', 'column2']
col_names = test
col_names.append('column3')
test
</code></pre>
<p>You can see that <code>test</code> also contains 'column3'. You should create copy of initial list and... | python|pandas|dataframe|scikit-learn|data-science | 0 |
350,241 | 64,104,482 | Why does networkx reduce number of nodes after adding edges | <p>I need to start this by saying that my code runs without any error messages, but I don't understand some of the results.</p>
<p>I create a graph in networkx from a pandas data frame, that has 398595 integer IDs.</p>
<pre><code># Create Graph
G = nx.Graph()
G.name = "Graph from Pandas"
# Add Nodes to Graph... | <ol>
<li>There are probably less unique IDs between ID1 and ID2 of df than there are in the ID column of test_df. The first thing I would check is if the unique IDs across ID1 and ID2 in df equals the number of nodes you display <code>len(pd.unique(df[['ID1','ID2']].values.ravel()))</code> (should equal 29348).</li>
<l... | python|python-3.x|pandas|graph|networkx | 1 |
350,242 | 64,072,451 | Merge dataframes and fill in blank values based on start/end dates | <p>I have pandas dataframe (df) with start and end dates for certain value (in this case 'currency').
I need to merge it with another dataframe (tbl) and fill in blank currency rows based on start/end dates from the first DF. NULL means no end date - so everything going forward. In this case everything after 01/11/2020... | <ol>
<li>First create an <code>as_of_date</code> column with <code>pd.date_range</code> in your dataframe that is a list of the dates between the start and end date per row with <code>lambda x:</code> (drop duplicates and keep last as well).</li>
<li>Explode the dataframe on the <code>as_of_date</code> in prepraration ... | python|pandas|dataframe|merge | 1 |
350,243 | 64,045,857 | Python Dataframe get max Value from max Date | <p>I have the following df:</p>
<pre><code> Date Email Amount
0 2020-04-09 john@xxmail.com 10
1 2020-05-09 john@xxmail.com 30
2 2020-08-20 mary@xxmail.com 40
3 2020-09-20 mary@xxmail.com 20
4 2020-05-04 nick@xxmail.com 10
5 2020-06-04 nick@xxmail.com 10
... | <p>The dates and quantities are grouped separately and combined in aggregate.</p>
<pre><code>df['Date'] = pd.to_datetime(df['Date'])
df_d = df.groupby('Email')['Date'].agg(max).reset_index()
df_a = df.groupby('Email')['Amount'].agg(max).reset_index()
final = pd.concat([df_d,df_a],axis=1)
final.columns = ['Date', 'Email... | python|dataframe|pandas-groupby | 0 |
350,244 | 63,840,510 | Pandas Ordered Categorical not working as intended | <pre><code>df = pd.DataFrame(['A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D'],
index=['excellent', 'excellent', 'excellent', 'good', 'good', 'good', 'ok', 'ok', 'ok', 'poor', 'poor'])
df.rename(columns={0: 'Grades'}, inplace=True)
cat_dtype = pd.CategoricalDtype(categories=['D', 'D+', '... | <p>Looks like you just need to assign the 'astype' to df['Grades']</p>
<pre><code>df['Grades'] = df['Grades'].astype(cat_dtype)
</code></pre>
<p>Filtering on your criteria outputs as:</p>
<pre><code>df[df['Grades'] > 'C']
Grades
excellent A+
excellent A
excellent A-
good B+
good B
g... | python|pandas | 2 |
350,245 | 63,893,092 | builtin keyerror while using pandas datareader to extract data | <p>I'm using a loop to extract data by using pandas datareader, the first two loops are working properly.
But from the third loop, the code starts to return a builtin keyerror which is unexpected. i wonder since the first two loops are working properly, why from the third loop it starts to return error? and how to fix ... | <p>For same tickers, there is no date column.</p>
<p>To catch the error and continue, try this code:</p>
<pre><code>def get_price(tickers): #input is a list or Series
result=pd.DataFrame()
for i in tickers:
try:
df=pd.DataFrame()
df['Adj Close']=web.DataReader(i,'... | python|pandas|yahoo-finance|datareader|pandas-datareader | 1 |
350,246 | 63,939,295 | AssertionError in Functional Model with Multiple Inputs when moving from TF1 to TF2 | <p>Hi I am trying to convert an old model from running on TF1 to TF2 and have been running into some issues. Been using google colab to switch between TF1 and TF2 and everything seems to run fine using TF1 but doesn't with TF2. I have replicated the problem with the short bit of code below.</p>
<pre><code>
from keras.l... | <p>You may modify your code like,</p>
<pre><code>from tf.keras.layers import *
from tf.keras import Model
def create_model():
inputA = Input(shape=(1,))
x = Dense(1)(inputA)
modelA = Model(inputs=inputA, outputs=x)
print(modelA.predict([0.1]))
inputB = Input(shape=(1,))
y = Dense(1)(inpu... | tensorflow|keras|neural-network|functional-programming|artificial-intelligence | 0 |
350,247 | 63,768,057 | Tensorflow: create y-indices from class labels | <p>I have class labels as:</p>
<pre><code>y = ["class1", "class2", "class3"]
</code></pre>
<p>for using them in a model, I want to convert these classes to y_indices as <em>1, 2</em> with methods of keras and/or tensorflow2.0.</p>
<p>What I am doing currently is:</p>
<pre><code>tokenizer =... | <p>You can't use a Tokenizer for this because the Tokenizer indexing starts at 1, and not 0. You can use <code>tf.where</code>:</p>
<pre><code>import tensorflow as tf
y = ['class3', 'class1', 'class1', 'class2', 'class3', 'class1', 'class2']
names = ["class1", "class2", "class3"]
labele... | python|numpy|tensorflow|keras|deep-learning | 1 |
350,248 | 64,138,509 | Can you modify the value of a Tensor in TensorFlow? | <p>Can you modify the value of a specific tensor?</p>
<p>For example:</p>
<pre><code>x = tf.zeros((2, 2))
x[0, 0] = 1 # pseudo-code
print(x) # <Tensor ... numpy=[[1, 0], [0, 0]]>
</code></pre> | <p>You can but you need to set the tensor to be a Variable and not a constant.</p>
<pre><code>import tensorflow as tf
import numpy as np
x = np.zeros((2,2))
x_var = tf.Variable(x)
x[0,0]=1
tf.assign(x_var ,x)
</code></pre> | tensorflow | 0 |
350,249 | 63,837,376 | How to Bar Chart (with Dates on x-axis) after Groupby operation | <p>I have a large df where I have used a group operation on "topic_nmf" and "dates" and counted occurrences of topic_nmf</p>
<p>sample DF</p>
<pre><code>df3 = pd.DataFrame({'topic_nmf':[0,0,0,0,0,1,1,1,2,2], 'date':['2020-08','2020-06','2020-05','2020-02','2019-11','2019-08','2020-03','2020-02', '20... | <p>Set <code>date</code> as index. By default, index is plotted on the <code>x axis</code>.</p>
<pre><code>df3.set_index('date').plot.bar()
df3.set_index('date').plot()
</code></pre>
<p>Following your comments. Please try</p>
<pre><code>df3.groupby(['date','topic_nmf'])['count'].sum().unstack().plot.bar()
#df3.groupby... | pandas|matplotlib | 1 |
350,250 | 63,800,812 | how to assert a dataframe value is NaN | <p>How can I assert a specific Pandas row/column value is nan ? I tried to assert a value from the iloc DataFrame value and from converting the Pandas DataFrame to Numpy array. It seems as if I can feed values in as np.nan but I can't test individual values.</p>
<pre class="lang-py prettyprint-override"><code>import ... | <p>you want</p>
<pre><code>assert np.isnan(df.iloc[2, 1])
</code></pre> | python|pandas|dataframe | 3 |
350,251 | 63,781,297 | What are the main differences between TensorFlowLite, TendorFlow-TRT and TensorRT? | <p>I am using the Coral devboard and the Nvidia Jetson TX2. And that is how I got to know about TensorFlow-Lite, TensorFlow-TRT and TensorRT.
I have some questions about them:</p>
<ol>
<li><p>Between TensorFlow-TRT and TensorRT:
When using a fully optimised/compatible graph with TensorRT, which one is faster and why?</... | <p>TensorRT is a very fast CUDA runtime for GPU only. I am using an Nvidia Jetson Xavier NX with Tensorflow models converted to TensorRT, running on the Tensorflow-RT (TRT) runtime. The benefit of TRT runtime is any unsupported operations on TensorRT will fall back to using Tensorflow.</p>
<p>Have not tried Tensorflow-... | tensorflow|tensorflow-lite|tensorrt|tensorflow-model-garden | 0 |
350,252 | 63,976,621 | How to Find Distance b/w Geographic Locations w/ Geodesic w/ Coordinates Separated Into 4 Different Columns To Create a Distance Column--ValueError | <p>I've created a shorter and fake data set. I've separated my Location_1 and Location_2 into two columns each to produce four columns total. Now I need to use <code>geodesic</code> on it. I am able to do it manual with a single observation when doing a test run. But I can't seem to make it work for entire columns of d... | <p>Inside a list comprehension <code>zip</code> the columns of <code>Loc_1</code> and <code>Loc_2</code> and calculate the <code>geodesic</code> distance for each pair of <code>loc_1</code> and <code>loc_2</code>:</p>
<pre><code>places_data['Distance'] = [geodesic(x, y).miles for x, y in zip(places_data['Loc_1'], place... | python|pandas|geolocation|distance | 0 |
350,253 | 63,972,800 | NumPy Boolean Array in Index | <p>Say we have two arrays</p>
<pre><code>a = np.array([1,2,3,4]).reshape(2,2)
b = np.array([True, False, False, True]).reshape(2,2)
</code></pre>
<p>gives</p>
<pre><code>a = [[1, 2],
[3, 4]]
b = [[True, False],
[False, True]]
</code></pre>
<p>We can do a[b] to get only the values of b that are true giving us... | <p>You can use either <a href="https://numpy.org/doc/stable/reference/generated/numpy.logical_not.html" rel="nofollow noreferrer"><code>np.logical_not</code></a> or the <a href="https://numpy.org/doc/stable/reference/generated/numpy.invert.html" rel="nofollow noreferrer"><code>~</code> operator</a>:</p>
<pre class="lan... | python|arrays|numpy | 1 |
350,254 | 64,020,759 | Matplotlib Plot and Colorbar issues | <p>I have the below plot, however, I am struggling with the 3 questions below....</p>
<ol>
<li>How can I move X-axis labels (1-31) to the top of the plot?</li>
<li>How can I change formating of the color bar from (7000 to 7k etc.)</li>
<li>How can I change the color from gray to another cmap like "Reds"?</li>... | <p>Let's try:</p>
<pre><code># create a single subplot to access the axis
fig, ax = plt.subplots()
# passing the `cmap` for custom color
plt.imshow(df, cmap='hot', origin='upper')
# draw the colorbar
cb = plt.colorbar(orientation="horizontal")
# extract the ticks on colorbar
ticklabels = cb.get_ticks()
# ... | python|pandas|plot|colorbar | 2 |
350,255 | 63,793,021 | pytorch does not save pre-trained model weights loaded and the parts of it in the final model | <p>I am currently working on pre-trained model on CIFAR-10 on my data, have removed the final fc layer of the model and have appended my own fc layer and softmax. There are seven networks which each of them are same as pre-trained part and are combined using appended fc layer. The following is pre-trained Network code... | <p>The problem is that <code>self.channels_dnsnets</code> is just a <code>list</code> and will not be part of the <code>state_dict</code>. Only <code>self.fc</code> and <code>self.softmax</code> will be registered into the <code>Module</code>. The simplest change would be to define it like this:</p>
<pre class="lang-py... | save|pytorch|pre-trained-model | 2 |
350,256 | 63,821,650 | ImportError: cannot import name 'auto' from 'tqdm' | <p>My Python version is 3.7.0 version</p>
<p>To import tensorflow_datasets,</p>
<pre><code>import tensorflow_datasets
</code></pre>
<p>I ran the code, but:</p>
<pre><code>ImportError: cannot import name 'auto' from 'tqdm'
</code></pre>
<p>So, how can I import the auto? When I searched the <code>auto</code> library:</p>... | <p>As far as I know, it's from <code>tqdm</code>, which I've only ever used for progress bars. In the <a href="https://github.com/tqdm/tqdm" rel="nofollow noreferrer">tqdm GitHub</a>, they import something from <code>tqdm.auto</code>. Also, running <code>from tqdm import auto</code> works for me, so I'm guessing it's f... | python|python-3.x|tensorflow|tqdm | -1 |
350,257 | 64,083,134 | Pandas converts integer numbers to real numbers when reading from Excel | <p>I recently started exploring python for analyzing excel data.
I have an excel file with two worksheets, each one with one matrix (with m = 1000 rows and n= 999 columns).The elements of both matrices are related to each other: one of the matrices concerns diplacement values and the other matrix concerns the force val... | <p>Let's make an example in a smaller scale (<em>3 * 3</em>).</p>
<p>I prepared an Excel file with 2 sheets and read them:</p>
<pre><code>displ = pd.read_excel('Input_2.xlsx', 'Displ')
forces = pd.read_excel('Input_2.xlsx', 'Forces')
</code></pre>
<p>Both DataFrames contain:</p>
<pre><code>displ fo... | excel|pandas|integer|floating | 0 |
350,258 | 63,846,476 | How to change degrees in polar plot projection (seaborn.FacetGrid) with datas from a column in my df? | <p>so, basically I am trying to plot this point-cloud in which different sets of points belongs to different given "families"(e.g. k1, k2, k3, k4...). The results is kinda nice, but untill now I am not being able to set the angles of the polar plot as I wish, that is giving the degree values from my dataframe... | <p>You have to convert the 'angle' column into degrees.</p>
<p>Here is an example with the cardioid curve. If you keep the angles in degrees:</p>
<pre><code>import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
##### Creating the dataframe
angle = np.linspace(0, 360, 100)
d = {'... | python|pandas|matplotlib|seaborn|polar-coordinates | 1 |
350,259 | 63,987,132 | How to use matplotlib to draw axes in groups | <p>The data in my csv likes this:</p>
<pre><code>staff_id clock_time device_id latitude longitude
1001 2020/9/20 7:26 d_1 24.48237852 118.1558955
1001 2020/9/20 5:30 d_1 24.59689407 118.0863806
1001 2020/9/18 4:17 d_2 24.59222786 118.0955275
1001 2020/9/16 3:33 d_2 24.59208312 118.0957197
1001 ... | <p>It groups the data and draws a scatter plot for each group from the resulting group objects in a loop process. Prepare the same color and marker type as the number of groups.</p>
<pre><code>gb = df.groupby(['staff_id','device_id'])
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
color ... | python|pandas|matplotlib | 1 |
350,260 | 63,797,679 | Is there a built-in way to load data augmentation configs from a file in TensorFlow/Keras? | <p>I'm looking for something like:</p>
<pre><code>data_augmentation = tf.keras.load_and_parse_data_aug_from_config("my_data_aug.yaml")
</code></pre>
<p>Then I can use it however I want, such as:</p>
<pre><code>model = tf.keras.Sequential([
data_augmentation,
layers.Conv2D(...
])
</code></pre>
<p>This base... | <p>I didn't find a way to do it in pure TensorFlow/Keras, but if you're using <a href="https://albumentations.ai/" rel="nofollow noreferrer">albumentations</a>, you can do it like so:</p>
<pre><code>import albumentations as A
transform = A.Compose([
A.RandomCrop(768, 768),
A.OneOf([
A.RGBShift(),
... | python|tensorflow|keras|data-augmentation | 0 |
350,261 | 64,080,209 | How do I call ExampleValidator to analyze split data sets? | <p>Using:</p>
<pre><code>Tensorflow version: 2.3.1
TFX version: 0.23.1
TFDV version: 0.24.0
TFMA version: 0.24.0
</code></pre>
<p>with an interactive context like so:</p>
<pre><code>from tfx.orchestration.experimental.interactive.interactive_context import \
InteractiveContext
context = InteractiveContext(
pipe... | <p>Thanks @Lorin S., for sharing the solution reference. For the benefit of community I am providing solution here (answer section) given by 1025KB in <a href="https://github.com/tensorflow/tfx/issues/2582#issuecomment-700865479" rel="nofollow noreferrer">github</a>.</p>
<blockquote>
<p>Added split in TFX 0.23 version,... | tensorflow2.0|tfx | 1 |
350,262 | 64,050,393 | How to Edit the Imported Word Document using python | <p>I do have a word document and I want to edit it. Here is the part of the document.
[Part of Word Document]: <a href="https://i.stack.imgur.com/g5JGO.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/g5JGO.jpg</a></p>
<p>I could upload it into jupyter notebook using <strong>python-docx</strong>.</p>
<p>I can a... | <p>You can just plainly set it as:</p>
<pre><code>doc.paragraphs[7].text = '85% of Student have some access'
</code></pre>
<p>In case you want to be teeny tiny bit more fancy about it:</p>
<pre><code>doc.paragraphs[7].text = doc.paragraphs[7].text.replace('98%','85%')
</code></pre> | python-3.x|pandas|docx|python-docx|doc | 1 |
350,263 | 63,789,705 | How to continuously collect data and save to a file every 5 second | <p>I am collecting data from a sensor with 200ms sampling rate. I need to collect and take average of its signal strength which can be retrieved from the received data. Currently I can collect and save data every minute. However, I need to shorten the time so that I can get more real-time average value.
Here is what my... | <p>If your data is in table format, then I suggest that you think in terms of database tables. There might me a little of a learning curve initially, but try using something simple like <strong>SQLite</strong>, or any other DB framework of your choice.
Then you can have either a shorter sleep time or multiple processes... | python|pandas|multithreading|sensors | 0 |
350,264 | 64,070,990 | Scipy sparse matrix – element-wise multiplication and division of only non-zero elements | <p>I have three sparse matrices <code>A</code>, <code>B</code>, and <code>C</code>, and I want to compute the element-wise result of: <code>(A*B)/C</code>, i.e. element-wise multiply <code>A</code> with <code>B</code>, then element-wise divide by <code>C</code>.</p>
<p>Naturally, since <code>C</code> is sparse, divisio... | <p>This is the best way to do this but if <code>C.data</code> has any 0s in it they'll still come out as <code>NaN</code>. How you choose to handle this probably depends on what exactly you're doing.</p>
<pre><code>A = sparse.csr_matrix(np.identity(100))
B = sparse.csr_matrix(np.identity(100) * 2)
C = sparse.csr_matrix... | python|numpy|scipy|time-complexity|sparse-matrix | 3 |
350,265 | 63,746,507 | Convert regression tree output to pandas table | <p>This code fits a regression tree in python. I want to convert this text based output to a table format.</p>
<p>Have looked into this ( <a href="https://stackoverflow.com/questions/53399214/convert-a-decision-tree-to-a-table">Convert a decision tree to a table</a> ) however the given solution doesn't work.</p>
<pre><... | <p>Modifying the the code from the <a href="https://stackoverflow.com/a/53400587/3087542">linked answer</a>:</p>
<pre class="lang-py prettyprint-override"><code>import sklearn
import pandas as pd
def tree_to_df(reg_tree, feature_names):
tree_ = reg_tree.tree_
feature_name = [
feature_names[i] if i != s... | python|pandas | 1 |
350,266 | 64,167,324 | NoModuleError: 'No module named pandas' while executing the .bat file | <p>I'm trying to a run .bat file, which has a link to python code in my PC.</p>
<p>This is the code in my <code>createExeFile_dummy.py</code> file</p>
<pre><code>import pandas as pd
df=pd.DataFrame({'Name':['check','Pqr','Abc'],'Age':[12,34,22],'Address':['icgb','ctgcad','kjsbfdjk']})
df.to_csv('D:/Test/chkexe.csv',ind... | <p>Depending on how you installed Spyder, it may be referencing a different Python executable (not <code>C:\Users\AppData\Local\Programs\Python\Python37\python.exe</code>) where you have <code>pandas</code> installed.</p>
<p>To check this, run</p>
<pre><code>import sys
print(sys.executable)
</code></pre>
<p>in both Spy... | python|pandas|batch-file | 1 |
350,267 | 63,908,359 | create new column in pandas dataframe based on criteria on different other columns | <p>I want to create a new column in pandas based on criteria on some other columns. Usually this can be done using np.select but I am wondering if it can be done differently. For example create a tag columnn with 'yes' based on values in cols I1=1,I2=2 and I3=3 else 'no'.</p>
<pre><code>df = pd.DataFrame({
"NA... | <p>I will do condition in <code>dict</code> then use <code>eq</code> with <code>all</code></p>
<pre><code>cond_d = {'I1':1,'I2':2,'I3':3}
df.iloc[:,1:].eq(cond_d ).all(1).map({True:'Yes',False:'No'})
Out[218]:
0 Yes
1 No
2 No
dtype: object
</code></pre> | pandas | 1 |
350,268 | 64,066,832 | Apply a function with multiple parameters in input in groupby pandas | <p>I would like to substitute the NaN and NaT values of the Value1 column, with others calculated with a function that takes in input Value2 and Value3 (if they exist) of the same row of Value1. This is done for each ID. To do this, I would use 'groupby' and then 'apply'.But I get an error: <em>'Series' objects are mut... | <p>The output of <code>func</code> is another <code>Series</code>, and pandas is not sure what you want to do with it - what would it mean to <code>apply</code> this series to the groups?</p>
<p>Is it that you want the values of this series to be assigned wherever there is a missing <code>Value1</code> in the original ... | python|pandas | 1 |
350,269 | 63,943,073 | Select only columns that contain specific character | <p>I have a df of numbers initially stored as all type str where sometimes the data in the columns is stored as a percent but <strong>its not always the same columns</strong>. I don't know which columns will be a percent or will be a number. If its stored as a percent I need to convert it to a decimal.</p>
<p>How can I... | <p>Here is one way using <code>filter</code> and <code>select_dtypes</code> to find the columns:</p>
<pre><code>cols = df.filter(like="col").select_dtypes("object").columns
</code></pre>
<p>Alternatively you can extract 1 row and find <code>%</code>:</p>
<pre><code>cols = df.columns[df.loc[0].astype... | python|python-3.x|pandas | 4 |
350,270 | 64,020,001 | How to remove leading masked elements in a numpy array? | <p>How to remove leading masked elements from a numpy array.
for example the masked array of [2 x 5] below:</p>
<pre><code>m_arr = [[- - 1 - 1]
[1 - - 1 1]]
</code></pre>
<p>output of removing leading masked element would be</p>
<pre><code>m_arr = [[1 - 1]
[1 - - 1 1]]
</code></pre>
<p>I tried using compresse... | <p>OK, make the masked array:</p>
<pre><code>In [96]: m_arr=np.ma.MaskedArray(np.arange(10).reshape(2,5),np.array([[1,1,0,1,0
...: ],[0,1,1,0,0]]))
In [97]: m_arr
Out[97]:
masked_array(
data=[[--, --, 2, --, 4],
[5, --, --, 8, 9]],
mask=[[ True, True, False, True, False],
[False, True, True... | python|python-3.x|numpy | 2 |
350,271 | 63,787,892 | Value Error while dividing two columns of a dataframe. (.all() and .any() are also not working) | <p>This is the dataframe info:</p>
<pre><code>new_final.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 12 entries, 1 to 13
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 DorW 12 non-null object
1 date ... | <p>If they are normal integers contained in lists, it should work in this way</p>
<pre><code>new_final['impression_to_pdp'] = new_final['pdp']/new_final['impressions']
</code></pre>
<p>but, if they are numpy arrays then you must do like</p>
<pre><code>import numpy as np
new_final['impression_to_pdp'] = np.divide(new_fi... | python|pandas|dataframe | 1 |
350,272 | 63,889,795 | Column creation on Dataframe with expression variant | <p>I need to create a weighted average column on a DataFrame with this expression:</p>
<pre><code>wa = pd.Dataframe()
i = 0
for i in range(10,0,-1):
wa[0][i] = 1/(2**i)
</code></pre>
<p>I need a DataFrame like this:</p>
<pre><code>wa = Index:[1/(2**10),1/(2**9),1/(2**8)...1/(2**0)]
</code></pre> | <p>I think this is what you need:</p>
<pre><code>import pandas as pd
import numpy as np
n = 10
out = [1/2**i for i, i in zip(range(n,0,-1), range(n,0,-1))]
print(out)
</code></pre>
<p>Output is here:</p>
<pre><code>[0.0009765625, 0.001953125, 0.00390625, 0.0078125, 0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5]
</code><... | python|pandas|dataframe | 0 |
350,273 | 46,757,866 | Nested lists of different lenghts from a Json to Pandas Dataframe | <p>I am having some issues with converting a JSON composed of Lists of different lenghts to a pandas dataframe. I get the JSON from a webpage like this: </p>
<pre><code>import requests, json
import numpy as np
r = requests.get('https:a_web_page')
data = r.json()
type(data)
</code></pre>
<p>From this I got as an out... | <pre><code>df=pd.DataFrame(data)
df=pd.concat([df.iloc[:,0:2],df[2].apply(pd.Series)],axis=1)
df.columns=list(range(df.shape[1]))
df
Out[63]:
0 1 2 3 4 5 6 7 8 \
0 1411333200000 0.00000 0.000 0.0 10.0 5.4014 0.42247 0.2517 0.0
1 1411419600000 0.00... | python|json|pandas|nested-lists | 0 |
350,274 | 46,722,122 | DataFrame merging with ordered indices and different columns | <p>I have two pandas data-frames, which I wanted to merge. The data-frames have different columns and overlapping indices. I want to merge them, keeping the order of indices intact. </p>
<p>Dataframe (d1)</p>
<pre><code> Dec 16 Dec 15
Balance Sheet
NON-CURRENT LIAB... | <p>Use <code>how=outer</code> with <code>merge</code> and <code>reindex</code> with custom order</p>
<pre><code>In [1424]: order_index = ['NON-CURRENT LIABILITIES', 'Deferred Tax Liabilities [Net]',
'Other Long Term Liabilities', 'Long Term Provisions',
'Tot... | python-3.x|pandas|join|merge | 0 |
350,275 | 46,895,485 | Pandas scan directories and take new Excel files into Dataframe | <p>I want to scan the Excel files in Python that have the same name in two different folders and add the most recent of these files to my Dataframe. How can I do that, can you help in this?</p> | <p>You could just use a for loop to iterate through the files and choose the one with the most recent "last modified" date, which can be accessed through the os module.</p>
<pre><code>import os
import pandas as pd
filelist = ['your/path/tofile1', 'your/path/tofile2', 'your/path/tofile3']
filedate = 0
for file in file... | python|python-3.x|pandas | 0 |
350,276 | 47,030,790 | Reshape stacked Pandas DataFrame | <p>I have the following DataFrame <code>df1</code>:</p>
<pre><code> df1 = pd.DataFrame(np.random.rand(4,2), columns = {"var1", "var2"})
df1["inst"] = ["A", "A", "B", "B"]
df1.set_index("inst", inplace = True)
df1 = df1.stack()
ipdb> df1
inst
A var1 0.191094
var2 0.100821
... | <p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.GroupBy.cumcount.html" rel="nofollow noreferrer"><code>cumcount</code></a> + <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html" rel="nofollow noreferrer"><code>set_index</code></a> and ... | python-3.x|pandas|reshape | 1 |
350,277 | 46,921,852 | One last issue getting DeepChem running with TensorFlow | <p>I'm trying to install the DeepChem multi objective deep learning code on a MacBook Pro with a Python 2.7 environment. I did a manual install of DeepChem and its required components and all seemed to go well, no errors. When I tried to run the test data I got an error "Failed to load the native TensorFlow runtime". ... | <p>Your question is really general and this is not really a tensorflow problem so much as a virtualenv/dependency question.</p>
<p>That said here are some possible fixes:</p>
<ul>
<li>are you sure you have activated the virtualenv (should show
environment in parentheses before the bash prompt)? If not use:
<code>sou... | python|tensorflow | 0 |
350,278 | 47,012,687 | Pandas series from dictionary | <p>Here's a fragment of my data.
I would like to convert this dictionary into a series with a multiindex. This seems aspect seems to work, however all values in the series are NaN?</p>
<pre><code>d = {(datetime.date(2017, 10, 19), 1026972): 24.91, (datetime.date(2017, 10, 19), 1026973): 10.68, (datetime.date(2017, 10,... | <p>Use multi index from tuples and set it as index, then pass the dict values to series. </p>
<pre><code>s = pd.Series(list(d.values()),index=pd.MultiIndex.from_tuples(d.keys()))
</code></pre>
<p>Output : </p>
<pre>
2017-10-19 1026974 654.70
1026973 10.68
1026972 24.91
dtype: floa... | pandas | 11 |
350,279 | 46,807,597 | face landmark detection with helen database | <p>I'm going to use CNNs for face landmark detection.(python and tensorflow)</p>
<p>The problem is images in Helen database have different scales.</p>
<p>I think I cannot just resize or crop images because the data is the positions of images.((x,y) coordinates)</p>
<p>however, I found a lot of papers(CNNs) tested th... | <p>What I would suggest to do:</p>
<ol>
<li>detect faces with open-cv (<a href="https://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html" rel="nofollow noreferrer">here</a>)</li>
<li>crop bounding box for every face</li>
<li>resize the cropped images to the resolution which is needed for the cnn</li>
</ol> | python|tensorflow|neural-network|face | 0 |
350,280 | 46,810,696 | Get order of subgroups in pandas dataframe | <p>I have a pandas dataframe that looks something like this:</p>
<pre><code>df = pd.DataFrame({'Name' : ['Kate', 'John', 'Peter','Kate', 'John', 'Peter'],'Distance' : [23,16,32,15,31,26], 'Time' : [3,5,2,7,9,4]})
df
Distance Name Time
0 23 Kate 3
1 16 John 5
2 32 Peter 2
3 15 ... | <p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sort_values.html" rel="nofollow noreferrer"><code>sort_values</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.GroupBy.cumcount.html" rel="nofollow noreferrer"><code>cumcount</code></... | python|pandas | 2 |
350,281 | 46,950,742 | Numpy Array shape changes when changing dtype | <p>Why does changing the dtype of elements of a numpy array changes the shape of the array? I am new to numpy and I was trying to change the dtype to np.float16 from existing np.int32. Doing that changed the shape of the array, but changing to np.float32 doesn't modify the shape.</p>
<pre><code>>>> import num... | <p>Because changing the data type of the array changes what the bytes that are actually stored mean, and how many of them make up one value.
Your initial array probably has the data type <code>int32</code>, therefore each of the four values consists of four bytes:</p>
<pre><code>a = np.array([1, 2, 3, 4], dtype=np.int... | python|arrays|numpy | 6 |
350,282 | 46,909,850 | Find the increase, decrease in column of Dataframe group by an other column in Python / Pandas | <p>In my dataframe i want to know if the <code>ordonnee</code> value are decreasing, increasing,or not changing, in comparison with the precedent value (the row before) and group by the column <code>temps</code>.</p>
<p>I already try the method of these post:
<a href="https://stackoverflow.com/questions/41886388/find... | <p>Use</p>
<pre><code>In [5537]: s = entry.groupby('temps').ordonnee.diff().fillna(0)
In [5538]: entry['variation'] = np.where(s.eq(0), '--',
np.where(s.gt(0), 'increase',
'decrease'))
In [5539]: entry
Out[5539]:
temps abcisse ord... | python|pandas|dataframe | 1 |
350,283 | 46,989,124 | How to add a line as Index in a table by using pandas? | <p>I have a question to use pandas.
I have a table like this : </p>
<p>0 A B C D</p>
<p>1 S D F G</p>
<p>......</p>
<p>and every element of first line is the index of every column. </p>
<p>But I want to add a line at the top of the table, and I want the new line to be the index of the table of every colomn, how sh... | <p>Can't comment due to rep but I am fairly confident this is a duplicate and you can find your answer here:</p>
<p><a href="https://stackoverflow.com/questions/26147180/convert-row-to-column-header-for-pandas-dataframe">Convert row to column header for Pandas DataFrame,</a></p> | python|pandas|sklearn-pandas | 0 |
350,284 | 47,082,237 | Replace a part of string if it is followed by /,- or * in pandas python | <p>i am quit new to Python and also in stack overflow. This platform is quit helpful for me to get what i wanted to perform code wise. I am working on a dataframe in pandas and I want to replace a part of string only if it is followed by <code>/ or - or *</code>. the sample string is-<br/> <code>MAA-BOM/MADRAS</code>.... | <p>Build a dictionary of mappings:</p>
<pre><code>m = {'MAA' : 'MADRAS', 'BOM': 'BOMBAY', 'MAD' : 'MADRID'}
</code></pre>
<p>Now, call <code>str.replace</code> on your column:</p>
<pre><code>df['Col'] = df['Col'].str.replace(r'.*?(?=[/*-])',
lambda x: m.get(x.group(), None))
</code></pre> | python|pandas | 0 |
350,285 | 46,809,278 | Scipy.signal method 'filtfilt()' doesn't recognized correctly | <p>It's my first time working with scipy.signal library and I am experimenting an error with the method <code>filtfilt()</code>.</p>
<p>This is the code I am trying to execute:</p>
<pre><code>Fs = 1000
# s is an array of numbers
a=signal.firwin(10, cutoff=0.5/(Fs/2))
ss = s - np.mean(s)
se = signal.filtfilt(a, 1, ss... | <p>I would guess you have different versions of scipy in use. The documentation of <a href="https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.signal.filtfilt.html" rel="nofollow noreferrer">filtfilt</a> says the 'gust' method was added in 0.16. I assume the method parameter does not exist in earlier ver... | python|numpy|scipy | 2 |
350,286 | 46,876,004 | Numpy: Masked elements in computation | <p>I have a function to built a polynomial from a given x: [1, x^2,x^3,x^4,...,x^degree]</p>
<pre><code>def build_poly(x, degree):
"""polynomial basis functions for input data x, for j=0 up to j=degree."""
D = len(x)
polyome = np.ones((D, 1))
for i in range(1, degree+1):
polyome = np.c_[polyome... | <p>Apparently when working with masked arrays one must consistently use the <code>numpy.ma</code> versions of the routines. Any departure from this, and numpy 'forgets' that masked elements are present.</p>
<pre><code>def build_poly(x, degree):
"""polynomial basis functions for input data x, for j=0 up to j=degree... | python|numpy|computation | 1 |
350,287 | 46,751,263 | How do I find the smallest difference between a given number and every element in a list in Python? | <p>Say I have:</p>
<p><code>[1, 2, 3, 4]</code></p>
<p>and the integer</p>
<p><code>6</code></p>
<p>I want to compare <code>6</code> with every element in the list and return the element with the smallest absolute value difference which in this case is <code>4</code>. Is there an efficient <code>Numpy</code> way to... | <p>You can use <code>argmin</code> on the absolute difference to extract the index, which can then be used to extract the element:</p>
<pre><code>a = np.array([1, 2, 3, 4])
a[np.abs(a - 6).argmin()]
# 4
</code></pre> | python|list|numpy|subtraction | 5 |
350,288 | 47,069,515 | How to fill the missing hour Values in a pandas DataFrame | <p>I have a pandas dataframe which is the output of a sql query which returns hourly values
if the values do not meet a particular Threshold.</p>
<pre>
date_date | hour24 | column
------------------------------------
2017-10-29 | 00:00 | 5.8055152395
2017-10-29 | 01:00 | 1.2578616352
2017-10-29 | 02:00 | -1.51... | <p>This is how it was done using eventually, using the inputs provided here:</p>
<p>A dataframe was created containing only the time series values:</p>
<pre><code>In [1]: df_time = pd.DataFrame(pd.date_range(start='20171029 00', end='20171030 00', freq='1H'), columns=['date_date'])
In [2]:df_time.head()
Out[2]:
... | python|pandas | 4 |
350,289 | 46,846,761 | Setting pandas dataframe value based on row and column conditions | <p>I have a fairly specific algorithm I want to follow.</p>
<p>Basically I have a dataframe as follows:</p>
<pre><code> month taken score
1 1 2 23
2 1 1 34
3 1 2 12
4 1 2 59
5 2 1 12
6 2 2 23
7 ... | <p>The reason for your values not being updated is that assignment to <code>iloc</code> updates the <em>copy</em> returned by the preceding <code>loc</code> call, so the original is not touched.</p>
<hr>
<p>Here's how I'd tackle this. First, define a function <code>foo</code>.</p>
<pre><code>def foo(df):
for i i... | python|pandas | 2 |
350,290 | 46,799,741 | How does numpy array typing interact with object? | <p>I am currently trying to implement a datatype that stores floats in an numpy array. However trying to assign an array with elements of this type with various lengths seems to obviously break the code. One would assign a sequence to an array element, which is not possible.</p>
<p>One can bypass this by using the da... | <p>The <code>object</code> dtype in Numpy simply creates an array of pointers to Python objects. This means you lose the performance advantage you usually get from Numpy, but it's still sometimes useful to do this.</p>
<p>Your last example creates a one-dimensional Numpy array of length two, so that's two pointers to... | python|arrays|python-3.x|numpy | 0 |
350,291 | 46,706,819 | Using pd.DataFrame.agg to create feature vectors | <p>I want to calculate some features for a collection of time series, or columns if you want. </p>
<p>I know I can use <code>pandas.DataFrame.agg</code> for that but I can't seem to able to give custom names to the resulting rolumns/rows of the DataFrame.</p>
<p>The code below does what I want:</p>
<blockquote>
<p... | <p>Here's one way.</p>
<pre><code>In [1023]: def f1(x):
...: return x.mean()
...:
In [1024]: def f2(x):
...: return x.std()
...:
In [1025]: df.agg([f1, f2], axis=0).T
Out[1025]:
f1 f2
s0 0.593445 0.282322
s1 0.554996 0.247396
s2 0.441740 0.321923
s3 0.379589 0... | pandas | 0 |
350,292 | 46,920,454 | how to replace multiple values with one value python | <p>How can I replace the data <code>'Beer','Alcohol','Beverage','Drink'</code> with only <code>'Drink'</code>.</p>
<pre class="lang-py prettyprint-override"><code>df.replace(['Beer','Alcohol','Beverage','Drink'],'Drink')
</code></pre>
<p>doesn't work</p> | <p>You <em>almost</em> had it. You need to pass a dictionary to <code>df.replace</code>.</p>
<pre><code>df
Col1
0 Beer
1 Alcohol
2 Beverage
3 Drink
</code></pre>
<p></p>
<pre><code>df.replace(dict.fromkeys(['Beer','Alcohol','Beverage','Drink'], 'Drink'))
Col1
0 Drink
1 Drink
2 Drink
3 Dr... | python|string|pandas|dataframe|replace | 23 |
350,293 | 46,939,588 | Selecting slices of a Pandas Series based on both index and value conditions | <p>I have a Pandas <code>Series</code> which contains acceleration timeseries data. My goal is to select slices of extreme force given some threshold. I was able to get part way with the following:</p>
<pre><code>extremes = series.where(lambda force: abs(force - RESTING_FORCE) >= THRESHOLD, other=np.nan)
</code></... | <p>It actually wasn't so simple to come up with a vectorized solution without looping.</p>
<p>You'll probably need to go through the code step by step to see the actual outcome of each method but here is short sketch of the idea:</p>
<h3>Solution outline</h3>
<ol>
<li>Identify all peaks via simple threshold filter</... | python|pandas|numpy | 3 |
350,294 | 46,989,813 | How to get the fraction of occurrences of a certain value in a Pandas Series? | <p>Suppose I have a <code>DataFrame</code> containing a column <code>A</code> which contains only values <code>'foo'</code> and <code>'bar'</code>, and I'd like to compute the fraction of <code>foo</code>s. One way to do this is by using Boolean selection together with the <code>__len__</code> function:</p>
<pre><cod... | <p>The pandas-native way is <code>series.value_counts(normalize=True)</code>:</p>
<pre><code>df.A.value_counts(normalize=True)
foo 0.625
bar 0.375
Name: A, dtype: float64
</code></pre>
<p>This shows all values, so if you're interested only in a single value and want the best performance, then the method from @... | python|pandas | 4 |
350,295 | 46,916,667 | Efficient way to sample a large array many times with NumPy? | <p><strong>If you don't care about the details of what I'm trying to implement, just skip past the lower horizontal line</strong></p>
<p>I am trying to do a bootstrap error estimation on some statistic with NumPy. I have an array <code>x</code>, and wish to compute the error on the statistic <code>f(x)</code> for whic... | <p>Since we are allowing repetitions, we could generate all the indices in one go with <code>np.random.randint</code> and then simply index to get <code>resamples</code> equivalent, like so -</p>
<pre><code>num_samples = 1000
idx = np.random.randint(0,len(x),size=(num_samples,len(x)))
resamples_arr = x[idx]
</code></p... | python|numpy|optimization|statistics|list-comprehension | 8 |
350,296 | 46,828,017 | How to efficiently update np array depending on index and value? | <p>I have an image of the sun, I found center and radius and now I want to process pixels differently if they are inside or outside the disk. The ideal solution would be to imterpolate the parameters of the processing function, in order to smoothly transition from disk to background.</p>
<p>Here is what I'm doing now:... | <p>Here's a vectorized way leveraging <a href="https://docs.scipy.org/doc/numpy-1.13.0/user/basics.broadcasting.html" rel="nofollow noreferrer"><code>NumPy broadcasting</code></a> -</p>
<pre><code>m,n = sun_img.shape
I,J = np.ogrid[:m,:n]
sq_dist = (I - center[0])**2 + (J - center[1])**2
valid_mask = sq_dist &... | python|image|numpy|image-processing|python-3.6 | 2 |
350,297 | 46,980,587 | Combine and split boolean arrays | <p>I have a list of boolean arrays constructed using the numpy where function, e.g.:</p>
<pre><code>A[0] = [False, False, True, True, True, False, False,False,False,False]
A[1] = [False, False, False, False,False,False, True, True, True,False]
A[2] = [False,True, True, True, False, False, False, False,False,False]
...... | <p>I am not sure what you mean when you say "Combine all arrays into one single array with length L that will contain all "True" values". However, the the second item, recovering the initial and final indices for all true windows was kinda fun:</p>
<pre><code>A = []
A.append([False,False,True, True, True, False,False... | python|arrays|numpy|boolean | 0 |
350,298 | 46,708,008 | numpy operation: convert green to red | <p>I have images that I would like to convert to red in case there is any green. If there's red, I'd like to keep it.</p>
<p>The images are in numpy arrays as follows:</p>
<p>x.shape
(50, 15, 3)</p>
<p>In a fist instance I would like to take the max value of the first two elements of the third dimension (R and G) an... | <p>It seems you have already figured out the second step. Here's one way to do the first step -</p>
<pre><code>x[...,0] = x[...,:2].max(axis=-1)
</code></pre>
<p>Alternatively, we can also use <code>np.maximum</code> for the element-wise max computation -</p>
<pre><code>x[...,0] = np.maximum(x[...,0], x[...,1])
</co... | python|numpy|python-imaging-library | 1 |
350,299 | 46,832,829 | Scipy.optimize.minimize objective function ValueError | <p>I am using scipy.optimize.minimize for a small optimization problem with 9 free variables. My objective function is basically a wrapper around another function, and if I evaluate my objective function, the return type is 'numpy.float32'... which is a scalar? However, I am getting the following error when attempting ... | <p>You may want to look at <a href="https://stackoverflow.com/questions/45867337/utilizing-scipy-optimize-minimize-with-multiple-variables-of-different-shapes">Utilizing scipy.optimize.minimize with multiple variables of different shapes</a>. What is important to understand is that if you want to use minimize with arra... | python|numpy|optimization|scipy | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.