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 |
|---|---|---|---|---|---|---|
357,900 | 38,858,198 | How can tensorflow feature columns be used for repeatable features? | <p>I would like to train a sparse logistic regression to classify users in two classes. One of my features is the users' interests which is non-exclusive (e.g. a user can be interested in cars, books and food) and variable in number: a user may have 5 interests, while another may have only 3, in contrast to the example... | <p>You could create a column for each interest (a boolean value for whether or not it's their interest). That should work if all interests are known. Another way to do it is to use one-hot encoding.</p>
<pre><code>E.g. Interests are cars, books and food.
001 is cars
010 is books
100 is food
101 is food and cars
etc.
<... | tensorflow|logistic-regression | 0 |
357,901 | 38,595,578 | Python pandas - construct multivariate pivot table to display count of NaNs and non-NaNs | <p>I have a dataset based on different weather stations for several variables (Temperature, Pressure, etc.),</p>
<pre><code>stationID | Time | Temperature | Pressure |...
----------+------+-------------+----------+
123 | 1 | 30 | 1010.5 |
123 | 2 | 31 | 1009.0 |
202 | ... | <p><strong>UPDATE:</strong> thanks to <a href="https://stackoverflow.com/questions/38595578/python-pandas-construct-multivariate-pivot-table-to-display-count-of-nans-and/38596301?noredirect=1#comment64580792_38596301">@root</a>:</p>
<pre><code>In [16]: df.groupby('stationID')[['Temperature','Pressure']].agg([nans, not... | python|pandas|dataframe|pivot-table|nan | 3 |
357,902 | 38,517,940 | Outer addition and subtraction in tensorflow | <p>Is the an equivalent operation (or series of operations) that acts like the numpy outer functions? </p>
<pre><code>import numpy as np
a = np.arange(3)
b = np.arange(5)
print np.subtract.outer(a,b)
[[ 0 -1 -2 -3 -4]
[ 1 0 -1 -2 -3]
[ 2 1 0 -1 -2]]
</code></pre>
<p>The obvious candidate <a href="https://www.... | <p>Use broadcasting:</p>
<pre><code>sess.run(tf.transpose([tf.range(3)]) - tf.range(5))
</code></pre>
<p>Output</p>
<pre><code>array([[ 0, -1, -2, -3, -4],
[ 1, 0, -1, -2, -3],
[ 2, 1, 0, -1, -2]], dtype=int32)
</code></pre>
<p>To be more specific, given <code>(3, 1)</code> and <code>(1, 5)</code> ... | python|tensorflow | 9 |
357,903 | 38,609,557 | PIL attribute error: Shape when creating an array | <p>I'm trying to warp two images of different sizes using PIL; specifically, by setting the shape (size) for future warped target image as a numpy array and I'm encountering AttributeError:</p>
<p>File "C:\Anaconda2\lib\site-packages\PIL\Image.py", line 632, in <strong>getattr</strong>
raise AttributeError(name)
A... | <p>I think Image objects have <em>size</em> attributes and arrays have <em>shape</em> attributes. Try renaming it in your code.
(See : <a href="http://effbot.org/imagingbook/image.htm" rel="nofollow">http://effbot.org/imagingbook/image.htm</a>)</p> | python|numpy|scipy|python-imaging-library | 1 |
357,904 | 38,579,358 | Processing groups of point-matrix multiplications with numpy | <p>Given two parallel arrays, one an array of rotation matrices, and the other an array of groups of 3D points, I'm looking for the fastest way to multiply each subgroup by the its corresponding matrix.</p>
<p>I was able to achieve what I want by looping over each group with numpy.einsum. I'm hoping there is a way to ... | <p>It's really straightforward: you've done most of the work yourself!</p>
<p>Just take the index corresponding to subgroups and put it on both sides of the einsum equation: that'll give you the desired array of dimension <code>(N_SUBGROUPS, N_GROUPS, 3)</code>.</p>
<p>Suppose we call the subgroup index <code>l</code... | python|arrays|numpy|matrix | 1 |
357,905 | 38,945,499 | Trying to flatten array in numpy | <p>I'm new to numpy and trying to flatten a 1000,1000 array created from a pandas dataframe. the code i've used is:</p>
<pre><code> lidor_array=lidor_df.values
print(lidor_array.shape)
lidor_array.flatten()
print(lidor_array.shape)
</code></pre>
<p>the shapes are output as (1000,1000) for both the pre ... | <p><code>flatten</code> is not performed in-place. It returns a copy:</p>
<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html</a></p>
<p>You could either do:</p>
<pre><code>lidor_arra... | python|numpy | 1 |
357,906 | 38,521,181 | How can i call syntaxnet from python file? | <p>We have successfully installed syntaxnet and we are able to get the parsed output by calling the command <code>echo 'open Book, which I have written with laboratory writer, with libreoffice writer.' | syntaxnet/demo.sh</code>.</p>
<p>Ideally what we want is calling syntaxnet from python file (more specifically from... | <p>Yes, You can call <code>syntaxnet</code> from python. You can use <code>subprocess</code> module or simply <code>os.system</code> command.</p>
<pre><code>os.system('syntaxnet/demo.sh')
</code></pre>
<p>or</p>
<pre><code>subprocess.call('syntaxnet/demo.sh')
</code></pre>
<p>Both works for me. Make sure to give th... | python|tensorflow|syntaxnet | 0 |
357,907 | 38,559,541 | Concatenate a set of column values based on another column in Pandas | <p>Given a Pandas dataframe which has a few labeled series in it, say <em>Name</em> and <em>Villain</em>.</p>
<p>Say the dataframe has values such: <br/>
<strong>Name</strong>: {'Batman', 'Batman', 'Spiderman', 'Spiderman', 'Spiderman', 'Spiderman'} <br/>
<strong>Villain</strong>: {'Joker', 'Bane', 'Green Goblin', 'El... | <p>This is a classic inner-join scenario. In <code>pandas</code>, use the <code>merge</code> module-level function:</p>
<pre><code>In [13]: df1
Out[13]:
Name Villain
0 Batman Joker
1 Batman Bane
2 Spiderman Green Goblin
3 Spiderman Electro
4 Spiderman Venom
5 ... | python|pandas | 8 |
357,908 | 38,627,780 | Matrix Multiplication TypeError | <p>I'm attempting to write a backpropagation algorithm and I'm encountering an error when attempting to perform a matrix multiplication. </p>
<p>I've created the following simple example to work with</p>
<pre><code># necessary functions for this example
def sigmoid(z):
return 1.0/(1.0+np.exp(-z))
def prime(z):
... | <p>There is a misplaced parenthesis on your last line. It should be</p>
<pre><code>print(np.dot(np.transpose(weights[-1]), delta))
</code></pre>
<p>instead of</p>
<pre><code>print(np.dot(np.transpose(weights[-1])), delta)
</code></pre> | python|numpy|matrix | 2 |
357,909 | 38,689,743 | what is the difference between x[1,2] and x[1][2] in hierarchy indexing for series in python? | <p>I have a series </p>
<pre><code>x=pd.Series(np.random.random(16),index=[[1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4],['a','b','c','d','a','b','c','d','a','b','c','d','a','b','c','d']])
</code></pre>
<p>that looks like this:</p>
<pre><code>1 a -0.068167
b -1.036551
c -0.246619
d 1.318381
2 a -0.119061
... | <p>This explanation is from the <a href="http://docs.scipy.org/doc/numpy/user/basics.indexing.html" rel="nofollow">numpy docs</a>, however I believe a similar thing is happening in pandas (which uses numpy inside, using "indexers" to provide a mapping between a (possibly) named index and the underlying integer-based in... | python|pandas|indexing|hierarchy | 2 |
357,910 | 38,709,841 | Comparing strings in same series (row) but different columns | <p>I ran into this problem with comparing strings between two columns. What I want to do is to: For each row, check whether the string is column A is included in column B and if so, print a new string 'Yes' in column C.</p>
<p>Column A contains NaN values (blank cells in the csv I imported).</p>
<p>I have tried:</p>
... | <p>This uses list comprehension, so it may not be the fastest solution, but works and is concise.</p>
<pre><code>df['C'] = pd.Series(['Yes' if a in b else 'No' for a,b in zip(df['A'],df['B'])])
</code></pre>
<p>EDIT: If you don't want to keep the values in C instead of overwriting them with 'No', you can do it like t... | python-3.x|pandas | 2 |
357,911 | 38,919,189 | Optimize 4D Numpy array construction | <p>I have a 4D array <code>data</code> of shape (50,8,2048,256) which are 50 groups containing 8 2048x256 pixel images. <code>times</code> is an array of shape (50,8) giving the time that each image was taken.</p>
<p>I calculate a 1st order polynomial fit at each pixel for all images in each group, giving me an array... | <p>Regarding the speed I see a lot of loops which is what should and often can be avoided due to the beauty of numpy. If I understand your problem fully you want to fit a first order polynom on 50 groups of 8 data points 2048 * 256 times. So for the fit the shape of your image does not play a role. So my suggestion is ... | python|arrays|numpy|optimization|slice | 0 |
357,912 | 38,964,819 | Warning: multiple data types in column of very large dataframe | <p>I have a fairly large pandas DataFrame read in from csv (~3 million rows & 72 columns), and I am getting warnings that some of the columns contain mixed data types:</p>
<pre><code>DtypeWarning: Columns (1,2,3,15,16,17,18,19,20,21,22,23,31,32,33,35,37,38,39,40,41,42,43,44,45,46,47,48,50,51,52,55,57,58,60,71) hav... | <p>consider the following <code>df</code></p>
<pre><code>df = pd.DataFrame(dict(col1=[1, '1', False, np.nan, ['hello']],
col2=[2, 3.14, 'hello', (1, 2, 3), True]))
df = pd.concat([df for _ in range(2)], ignore_index=True)
df
</code></pre>
<p><a href="https://i.stack.imgur.com/hCb2G.png" rel="n... | python|pandas|dataframe | 11 |
357,913 | 38,834,028 | Use a.empty, a.bool(), a.item(), a.any() or a.all() | <pre><code>import random
import pandas as pd
heart_rate = [random.randrange(45,125) for _ in range(500)]
blood_pressure_systolic = [random.randrange(140,230) for _ in range(500)]
blood_pressure_dyastolic = [random.randrange(90,140) for _ in range(500)]
temperature = [random.randrange(34,42) for _ in range(500)]
respir... | <p>As user2357112 mentioned in the comments, you cannot use chained comparisons here. For elementwise comparison you need to use <code>&</code>. That also requires using parentheses so that <code>&</code> wouldn't take precedence. </p>
<p>It would go something like this:</p>
<pre><code>mask = ((50 < df['h... | python|pandas | 8 |
357,914 | 38,867,689 | A faster discrete Laplacian than scipy.ndimage.filters.laplace for small arrays | <p>My spends the vast bulk of its computational time in <a href="http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.ndimage.filters.laplace.html" rel="nofollow"><code>scipy.ndimage.filters.laplace()</code></a></p>
<p>The main advantage of <code>scipy</code> and <code>numpy</code> is vectorised calculatio... | <p>The problem was rooted in <code>scipy</code>'s excellent error handling and debugging. However, in the instance the user knows what they're doing it just provides excess overhead.</p>
<p>This code below strips all the <code>python</code> clutter in the back end of <code>scipy</code> and directly accesses the <code>... | python|c++|numpy|filter | 2 |
357,915 | 62,945,006 | Creating a hierarchical index from scratch | <p>I'm trying to create a dataframe like this from scratch, as in I have no csv that I can read in data from.</p>
<pre><code> A B
window
1H 0.1 1
2
3
0.2 1
2
3
6H 0.1 1
... | <p>We have <code>MultiIndex</code></p>
<pre><code>idx=pd.MultiIndex.from_product([['1H', '6H', '12H', '24H'],[0.1,0.2],[1,2,3]],names=['Windows', 'A','B'])
</code></pre> | python|pandas | 2 |
357,916 | 62,979,176 | Trying to custom train MobilenetV2 with 40x40px images - wrong results after training | <p>I need to classify small images in 4 different categories, +1 "background" for false detection.</p>
<p>While training the loss quickly drop to 0.7, but stay there even after 800k steps. In the end, the frozen graph seems to classify most images with the background label.</p>
<p>I'm probably missing somethi... | <p>Change your learning rate, maybe start from the usual choice of 3e-5.</p> | tensorflow|machine-learning|tf-slim|mobilenet | 1 |
357,917 | 62,950,895 | Concate 2 dfs by a condition | <p>I have 2 dfs</p>
<pre><code>import pandas as pd
list_columns = ['Number', 'Name', 'Age']
list_data = [
[121, 'John', 25],
[122, 'Sam', 26]
]
df1 = pd.DataFrame(columns=list_columns, data=list_data)
Number Name Age
0 121 John 25
1 122 Sam 26
</code></pre>
<p>and</p>
<pre><code>list_co... | <p>Use <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.set_index.html" rel="nofollow noreferrer"><code>DataFrame.set_index</code></a> on <code>df1</code> and <code>df2</code> to set the index as column <code>Number</code> and use <a href="https://pandas.pydata.org/pandas-docs/stable... | python-3.x|pandas|dataframe | 1 |
357,918 | 63,096,262 | How to filter not in records from a dataframe using values from a another dataframe? | <p>I have 2 dataframes <code>Source</code> and <code>Target</code> .I want to select the rows from source datafame which dont have matching version value in target. Datatypes of version in both dataframes are object.</p>
<p>How can this be done?</p>
<pre><code>Source
kg from to version
0.5 AU DE 2019-12-02 1... | <p>try this</p>
<pre><code>Source[~Source['version'].isin(Target['version'])]
</code></pre>
<p>This will exclude any rows of <code>Source</code> where <code>version</code> exists in <code>Target</code>.</p> | python|pandas|dataframe | 2 |
357,919 | 63,179,773 | How to append pandas data-frame in loop using python | <p>I am facing some issue when appending data-frame in loop:</p>
<p>I have a dataframe which has following structure:</p>
<p><code>df</code></p>
<pre><code>A B C
1 2 3
4 5 6
7 8 9
</code></pre>
<p>Then I write a code:</p>
<pre><code>alpha=[0.10,0.05,0.01]
beta=[0.10]
error_est=[0.10,0.20,0.25]
</code></pre>
<p>Then I i... | <p>This code is setting all the rows in the table to the same value:</p>
<pre><code>df['sample_statistics']="alpha="+str(a)+"_"+"beta="+str(b)+"_"+"moe="+str(error)
df['required_sample_size']=req_samp_size
</code></pre> | python-3.x|pandas | 0 |
357,920 | 62,945,188 | python - keep duplicates if two columns equal | <p>I have a dataset that looks like below:</p>
<pre><code>col1. col2. col3.
a b c
a d x
b c e
s f e
f f e
</code></pre>
<p>I need to drop duplicates in <code>col3</code> if <code>col1</code> differs from <code>col2</code>. The result looks like:</p>
<pre><code>c... | <p>Yes we can do <code>argsort</code></p>
<pre><code>df = df.iloc[df.eval('col1==col2').argsort()].drop_duplicates('col3',keep='last')
col1 col2 col3
0 a b c
1 a d x
4 f f e
</code></pre> | python|pandas | 3 |
357,921 | 63,254,389 | With Statement inside functions | <p>So I can't get the code inside the function 'Display_File' to run. All it does is yell about bad indentation, too much, or not enough. I've tried every indentation possible and nothing works. I'm assuming I can't use a with statement inside a function. I use that code outside of the function and it works fantastic.<... | <p>It yells about indentation because your for-loop and if-statement are not indented:</p>
<pre><code>def display_file():
skipcnt = 0
with open(filename) as f: # auto closes after loop
for row in f:
skipcnt += 1
if "Tension" in row and "Elong" in row: # top ... | python-3.x|pandas|tkinter | 0 |
357,922 | 62,918,889 | Transform complex/flattened JSON into DataFrame | <p>I have an complex/nested JSON, that i need to transform into DataFrame (Python). I could get the first part, but i'm struggling to solve the second part.</p>
<pre><code>import requests
from pandas.io.json import json_normalize
import json
url = 'url'
headers = {'api-key':'key'}
resp = requests.get(url, headers = ... | <p>unpacking a nested json is not trivial, you can use a recursive approach to solve this problem.</p>
<p>If you have a fixed json structure, like you showed, a simpler approach would be the following.</p>
<pre><code>import pandas as pd
def unpack(data):
f = {}
for k,v in data.items():
if isinstance(v, ... | python|json|pandas|dataframe | 1 |
357,923 | 63,087,425 | How to pivot N observations of a time series column at a time | <p>I have a dataframe like this</p>
<pre><code> date
2018-02-28 09:00:00 78700.0
2018-02-28 10:00:00 78900.0
2018-02-28 11:00:00 78100.0
2018-02-28 12:00:00 78100.0
2018-02-28 13:00:00 77500.0
...
2018-11-30 11:00:00 70000.0
2018-11-30 12:00:00 69800.0
2018-11-30 13:00:00... | <p>There is a way of achieving your desired output using a <a href="https://en.wikipedia.org/wiki/Hankel_matrix" rel="nofollow noreferrer">Hankel matrix</a> and some array manipulation. You can construct a Hankel matrix with the <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.hankel.html#scip... | python|pandas|dataframe|scipy | 1 |
357,924 | 63,249,766 | Check Multiple condition for same row | <p>I have to compare 2 different sources and identify all the mismatches for all <code>IDs</code></p>
<p><code>Source_excel</code> table</p>
<pre><code>+-----+-------------+------+----------+
| id | name | City | flag |
+-----+-------------+------+----------+
| 101 | Plate | NY | Ready |
| 102 | ... | <p>You could do:</p>
<pre><code>df = pd.merge(Source_excel, Source_dw, on = 'ID', how = 'left', suffixes = (None, '_dw'))
</code></pre>
<p>This will create a new dataframe like the one you want, although you'll have to reorder the columns as you want. Note that the <strong>'_dw'</strong> is a suffix and not a prefix in... | python|python-3.x|pandas|dataframe | 1 |
357,925 | 62,932,765 | np.argamx doesn't return integer | <p>I have some onehot encoded data called testoutput, which has shape (1000,14).</p>
<p>I want to decode it, so following some advice I found online I used the following code:</p>
<pre><code># go from onehot encoding to integer
def decode(datum):
return np.argmax(datum)
predictedhits=np.empty((1000))
for i in rang... | <p>You've misdiagnosed the problem. <code>numpy.argmax</code> is not returning an instance of <code>numpy.float64</code>. Rather, <code>predictedhits</code> has float64 dtype. Storing any value into that array stores it as a 64-bit float, and retrieving <code>predictedhits[i]</code> from the array produces a <code>nump... | python|numpy|one-hot-encoding | 3 |
357,926 | 62,911,613 | A fast, efficient way to calculate time differences between groups of rows in pandas? | <p>Let's say I have this table in a DataFrame, with the dates several cars have been refilled:</p>
<pre><code>+-------+-------------+
| carId | refill_date |
+-------+-------------+
| 1 | 2020-03-01 |
+-------+-------------+
| 1 | 2020-03-12 |
+-------+-------------+
| 1 | 2020-04-04 |
+-------+---------... | <p>using native pandas methods over a <code>df.groupby</code> should give significant performance boost over a "native python" loop:</p>
<pre class="lang-py prettyprint-override"><code>df['time_elapsed'] = df.groupby('carId')['refill_date'].diff()
</code></pre>
<p>Here's a small benchmark (on my laptop, YMMV.... | python|pandas|dataframe | 3 |
357,927 | 63,027,134 | How to separate columns values to create a new different column | <p>I have a dataframe which looks like this:</p>
<p><a href="https://i.stack.imgur.com/0F3zh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0F3zh.png" alt="enter image description here" /></a></p>
<p>It kinda looks like a tuple. But what I want to do is to take all the values after the comma and put... | <p>using <code>.str</code> will unpack tuple</p>
<pre><code>In [32]: df = pd.DataFrame({"resultado":[(1,pd.np.NaN),(1,1),(1,2),(2,1),(2,2),(
...: 2,pd.np.NaN),(3,1),(3,2),(3,pd.np.NaN)],"amount":[735709,688554,601864,
...: 1055853,693378,596613,196078,182715,122275]})
In [33]: df['resultad... | python|pandas|dataframe|tuples | 2 |
357,928 | 63,237,610 | How to convert rows with list of strings to multiple columns | <p>I would like to have a dataframe that looks like as follows:</p>
<pre><code>Net greg Lukas mark Chris Lucy Mike
greg 1 0 1 0 0 0
Lukas 0 0 0 0 0 1
mark 0 0 1 1 0 0
Chris 0 0 1 1 0 0
Lucy 0 0 0 0 1 0
Mike ... | <p>I understand your question as converting from column <code>L</code> to one-hot-encoder. You previous question seems asking for the same. I don't understand why you marked <code>accepted</code> for that question while the answer doing the opposite. You may try this way</p>
<pre><code>df_final = df[['Net']].join(df.L.... | python|pandas | 0 |
357,929 | 63,096,908 | BERT + custom layer training performance going down with epochs | <p>I'm training a classification model with custom layers on top of BERT. During this, the training performance of this model is going down with increasing epochs ( after the first epoch ) .. I'm not sure what to fix here - is it the model or the data?</p>
<p>( for the data it's binary labels, and balanced in the numbe... | <p>Remember that fine-tuning a pre-trained model like Bert usually requires a much smaller number of epochs than models trained from scratch. In fact <a href="https://arxiv.org/pdf/1810.04805.pdf" rel="nofollow noreferrer">the authors of Bert recommend between 2 and 4 epochs</a>. Further training often translates to ov... | tensorflow|machine-learning|nlp|language-model | 3 |
357,930 | 62,996,329 | Python : compare two list of strings in a Pandas dataframe | <p>I would like to check if each word in the labels list exist in each list in the column 'bigrams'.</p>
<p>And if one these words exist in the bigram list, I would like to replace the label none by the word that exists.</p>
<p>I tried to write two consecutive for loop but it doesn't work. I also tried a comprehension ... | <p>You can use <code>pd.Series.str.extract</code></p>
<pre><code>df = pd.DataFrame({'bgrams': [['hello','goodbye'],['dog','cat'],['cow']], 'label':[None,None,None]})
df
# bgrams label
#0 [hello, goodbye] None
#1 [dog, cat] None
#2 [cow] None
labels=['cat','goodbye']
regex='('+'|'.jo... | python|pandas|dataframe | 1 |
357,931 | 63,289,566 | Keras Attention Layer on sequence to sequence model TypeError: Cannot iterate over a tensor with unknown first dimension | <p>I am using Tensorflow <code>2.1.1</code> and trying to build a sequence to sequence model with Attention.</p>
<pre><code>latent_dim = 300
embedding_dim=100
batch_size = 128
# Encoder
encoder_inputs = tf.keras.Input(shape=(None,), dtype='int32')
#embedding layer
enc_emb = tf.keras.layers.Embedding(x_voc, embeddin... | <p>the error is because keras Attention output 1 tensor while you are expecting 2. you need to change</p>
<pre><code>attn_out, attn_states = tf.keras.layers.Attention()([encoder_output, decoder_output])
</code></pre>
<p>into</p>
<pre><code>attn_out = tf.keras.layers.Attention()([encoder_output, decoder_output])
</code>... | python|tensorflow|machine-learning|keras|deep-learning | 6 |
357,932 | 63,129,794 | get the index of element in NumPy array | <p>I have a Numpy integer array with a lot of duplicate elements.</p>
<p>For example:</p>
<pre><code>a = np.random.randint(0,5,20)
a
Out[23]:
array([3, 1, 2, 4, 1, 2, 4, 3, 2, 3, 1, 4, 4, 1, 2, 4, 2, 4, 1, 1])
</code></pre>
<p>There are two cases:</p>
<ol>
<li>if one element is less than 4, get all the indexes of this ... | <p>You can do it quite easily, using <em>Pandas</em>.</p>
<p>First convert your array to a <em>pandasonic</em> <em>Series</em>:</p>
<pre><code>s = pd.Series(a)
</code></pre>
<p>Then:</p>
<ul>
<li>Group it by its value.</li>
<li>Apply to each group a function, which:
<ul>
<li>for groups of size <em>4</em> or smaller ret... | python|numpy|pytorch | 1 |
357,933 | 63,087,868 | Load data for Mask RCNN | <p>I want to train Mask-RCNN on my own dataset. I already have the segmented images (ground truths) of leaves which look something like the image below:</p>
<p><a href="https://i.stack.imgur.com/0OUD7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0OUD7.png" alt="rcnn train image" /></a></p>
<p>How ... | <p>Since Mask RCNN is pre-trained on COCO dataset,you need to train it with these images. For that purpose you have to label them and train it. Since a mask is involved use a tool such as VGG annotator to do the necessary annotation and labelling, it will generate a json file depending on your classes. Later based on y... | tensorflow|computer-vision|image-segmentation | 0 |
357,934 | 62,915,972 | find cells with specific value and replace its value | <p>Using pandas I have created a csv file containing 2 columns and saved my data into these columns. something like this:</p>
<pre><code>fist second
{'value': 2} {'name': 'f'}
{'value': 2} {'name': 'h'}
{"value": {&... | <p>Something like this might work.</p>
<pre><code>first=[{'value': 2} , {'value': 2} , {"value": {"data": {"n": 2, "m":"f"}}}, {"data": {"n": 2, "m":"f"}}]
second=[{'name': 'f'}, {'name': 'h'}, {'name': 'h'}, {'name': 'h'}]
df = ... | python|pandas|csv | 0 |
357,935 | 63,064,803 | Cannot CMake NGraph on Raspberry Pi due to NGRAPH_VERSION | <p>The full build log is below</p>
<p>I am building following NGraph instructions on <a href="https://github.com/NervanaSystems/ngraph" rel="nofollow noreferrer">https://github.com/NervanaSystems/ngraph</a></p>
<p>Looking at these I am assuming these variables</p>
<pre><code>NGRAPH_VERSION
NGRAPH_VERSION_SHORT
NGRAPH_A... | <p>I suggest you use a validated OpenVINO toolkit release with all the components (including ngraph). You can download the latest Raspberry Pi OpenVINO version from <a href="https://download.01.org/opencv/2020/openvinotoolkit/2020.4/" rel="nofollow noreferrer">https://download.01.org/opencv/2020/openvinotoolkit/2020.4/... | linux|tensorflow|cmake|openvino | 0 |
357,936 | 63,106,554 | Pandas column multi-index to rows | <p>I'm using <a href="https://pypi.org/project/yfinance/" rel="nofollow noreferrer">yfinance</a> to download the price history for multiple symbols, which returns a dataframe with multiple indexes. For example:</p>
<pre><code>import yfinance as yf
df = yf.download(tickers = ['AAPL', 'MSFT'], period = '2d')
</code></pre... | <p>This looks like a simple stacking operation. Let's go with</p>
<pre><code>df = yf.download(tickers = ['AAPL', 'MSFT'], period = '2d') # Get your data
df.stack(level=1).rename_axis(['Date', 'symbol']).reset_index(level=1)
</code></pre>
<p>Output:</p>
<pre class="lang-none prettyprint-override"><code> symbol... | python|pandas|multi-index|yfinance | 1 |
357,937 | 63,141,837 | Python BeautifulSoup4 Parsing: Hidden html elements on Yahoo Finance | <p>I am analyzing the balance sheet of Amazon on Yahoo Finance. It contains nested rows, and I cannot extract all of them. The sheet looks like this:
<a href="https://i.stack.imgur.com/UcFMg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UcFMg.png" alt="AMZN Balance Sheet" /></a></p>
<p>I used Beaut... | <p>You may have to click the "Expand All" button to see the additional rows. Refer to this thread to see how to simulate the click in Selenium: <a href="https://stackoverflow.com/questions/21350605/python-selenium-click-on-button">python selenium click on button</a></p> | python|pandas|parsing|beautifulsoup | 1 |
357,938 | 63,283,196 | Match new shapely Point to a series of shapely polygons - fast | <p>I have a Series of Shapely Polygons (>1000), which do not overlap. And I want to introduce a new shapely point and want to know fast, in which polygon the point would be. I have a for loop for this but I am looking for a method that would be faster.</p>
<pre><code>from shapely.geometry import Point
from shapely.g... | <p>The for-loop is not the problem in this case: The point in polygon test is slow. Optimizing your code means optimizing the number of point in polygon tests, which is typically done using a spatial index. This answer: <a href="https://gis.stackexchange.com/a/119935">https://gis.stackexchange.com/a/119935</a> from GIS... | python|pandas|shapely | 0 |
357,939 | 62,910,268 | How to create a conv1d for an array of multiple dimensions | <p>Here is my problem :</p>
<p>Suppose I am studying cancerous cells,
To simplify let's say I am watching 1 tumor.
each tumor will have its average oversize cells rate, average abnormal shape cells rate
I am using data taken once every month over 12 months
What I was thinking was having for each tumor an array of tuple... | <p>keras/tensorflow doesn't handle tuple data format. the simplest data format accepted by keras is numpy arrays. Following your code snippet, this is simply to impose</p>
<pre><code>dataset = []
for i in range(1000):
train = []
for j in range(0,12):
train.append([np.random.rand(), np.random.rand(), np... | tensorflow|keras|tf.keras | 2 |
357,940 | 63,066,794 | trying to make datasets from *.npy file . Failed to convert a NumPy array to a Tensor | <p>Looking for help!
I have this 'Data.npy' which contains some images and labels. it looks likes this:</p>
<pre><code>print(Data)
[[array([[0.57647059, 0.68235294, 1. , ..., 0.92156863, 0.92156863,
0.92156863],
[0.57647059, 0.7372549 , 0.85490196, ..., 0.92156863, 0.92156863,
0.92156863],... | <p>Instead of passing <code>Img</code> and <code>Label</code> directly to <code>tf.data.Dataset.from_tensor_slices</code>, you should follow the steps mentioned below:</p>
<pre><code># Load the training data into two NumPy arrays, for example using `np.load()`.
with np.load("Data.npy") as data:
Img = data[&... | python|numpy|tensorflow | 0 |
357,941 | 63,024,160 | Convert CSV entries into list of tuples without changing data types | <p>My CSV entry is as follows:</p>
<pre><code>1500, 'data', '10.10.10.1', 2.0, 1
1501, 'header', '10.10.10.14', 2.1, 0
...
</code></pre>
<p>I want to load it into my program this way:</p>
<pre><code>[(1500, 'data', '10.10.10.1', 2.0, 1), (1501, 'header', '10.10.10.14', 2.1, 0), ...]
</code></pre>
<p>I am trying to do t... | <p>The CSV library is not doing any conversion, the file is a string. It is up to the script to convert each value as required. For example:</p>
<pre><code>import csv
with open("input.csv", "r", newline="") as f_in:
csv_in = csv.reader(f_in, quotechar="'", skipinitialspace=T... | python|pandas|csv | 0 |
357,942 | 63,280,379 | Greatest Small date | <p>I have a two date columns let's say A and B in two separate tables. A contains the information of the date of test and column B contains date at which the factory was calibrated. I want to extract information of how many days has been passed since the factory was last calibrated.</p>
<p>For example:</p>
<pre><code>A... | <p>Take the smallest date as reference 0 and convert other dates into days with respect to 0(smallest date)</p>
<p>A = [2,3,4,5]</p>
<p>B = [0,4]</p>
<p>for each value of A, <em><strong>perform a binary search to find the nearest smallest or equal value in B...</strong></em> Their subtraction will be the Days_Passed si... | python|arrays|pandas|algorithm|binary-search | 0 |
357,943 | 62,995,507 | How to create a matplotlib graph with a secondary y-axis? | <p>I would like to create a line graph using matplotlib, where <code>COMP</code> and <code>MKR</code> are on one axis, and <code>LEND</code>, <code>KNC</code> are on a secondary y-axis. The X-axis should be the date column. I only want dates from <code>2020-07-18</code> to <code>2020-07-20</code>. The below output is a... | <p>You can use <code>loc</code> to extract data in the date range, and <code>plot</code>:</p>
<pre><code>df.loc['2020-07-18':'2020-07-20'].plot(y=['COMP', 'MKR','LEND','KNC'],secondary_y=['LEND','KNC'])
</code></pre>
<p>Output:</p>
<p><a href="https://i.stack.imgur.com/FxCE2.png" rel="nofollow noreferrer"><img src="htt... | python|pandas|matplotlib|graph | 1 |
357,944 | 63,160,024 | How to convert class 'sympy.core' to 'number' or 'float' for optimization? | <p>I'm a Python initiator and I'd like to solve the following problems, but I don't know what the cause is.I approached the problem using 'fsolve' an optimization tool.</p>
<p>First of all, I'm trying to solve a nonlinear equation, but I've approached it in two cases. One case worked out well. But I can't find another ... | <p>To work in in <code>fsolve</code> your <code>function</code> has to run with something like the <code>x0</code> value.</p>
<p>In the first case:</p>
<pre><code>In [1]: def function(v):
...:
...: b_1 = v[0]
...: b_2 = v[1]
...:
...: return (2*b_1 + 2*b_2/3,2*b_1/3... | python|numpy|class|scipy|sympy | 1 |
357,945 | 63,049,638 | Label Shape mismatch in Tensorflow | <p>I am beginner at tensorflow. i want to build a simple model but i got this error.
i think it's because labels but i don't know how to fix it.
i bulid my dataset from directory files with tf.data.Dataset.</p>
<p>this is data set:</p>
<p>visit : <a href="https://i.stack.imgur.com/H2EQT.jpg" rel="nofollow noreferrer">h... | <p>the problem solved by using batch size and step_per_epoch variables.</p>
<pre><code>train_ds = train_ds.map(parse_image, num_parallel_calls=AUTOTUNE)
train_ds = train_ds.cache()
train_ds = train_ds.batch(BATCH_SIZE, drop_remainder=True).repeat()
train_ds = train_ds.prefetch(buffer_size=AUTOTUNE)
</code></pre>
<p>and... | tensorflow|machine-learning|keras|label|reshape | 0 |
357,946 | 62,948,946 | How can I deal with large data for this complicated scenario ? Recursive CTE and Pandas are not working? | <p><a href="https://i.stack.imgur.com/w1bzN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w1bzN.png" alt="enter image description here" /></a></p>
<p>My scenario:</p>
<ul>
<li>User A is (fraudster).</li>
<li>User B is not (fraudster). However, the system will not allow user B
to do any action. Beca... | <p>The problem here (for the MySQL part) seems to be your stop condition. You keep track of the list of ids to prevent infinite loops (e.g. <code>A,B,C,D</code>). Unfortunately, that column will have the datatype of "id", maybe <code>varchar(10)</code>, which effectively means your track list has a limited le... | python|mysql|pandas | 1 |
357,947 | 63,301,979 | How to remove all string values that precede a character in pandas? | <p>I have the following dataframe:</p>
<pre><code>data = {'Name':['Square_Train_1', 'Stims1/Neut/32Neut1.jpg', 'Square_Train_2',
'Stims1/Neg/114Neg1.jpg', 'Square_Train_3',
'Stims1/Pos/129Pos1.jpg', 'Stims1/Neut/58Neut1.jpg',
'Stims1/Neg/13Neg1.jpg', 'Stims1/Pos/5Pos1.jpg',
'Stims1/Pos/25Pos... | <p>What it really looks like you're trying to do is grab just the filename and drop the rest of the directory from the filepath. If that is the case, I would use <code>df.apply</code> with <code>os.path.basename</code></p>
<pre><code>>>> import os
>>> df['Name'] = df['Name'].apply(os.path.basename)
</... | python|pandas | 3 |
357,948 | 63,228,494 | Pandas equivalent for SQL - arithmetic expression within aggregate function | <p>I am a pandas newbie coming from a SQL background although have some exposure to Python.</p>
<p>I was wondering if there is a simple way to do the following SQL code in pandas dataframe:</p>
<pre><code>Select
A,
Sum(B/C) value
From
Table
Group by
A
</code></pre>
<p>Below is all I got so far there doesn't see... | <p>try this,</p>
<pre><code>df.assign(value = df.B.div(df.C)).groupby('A')['value'].sum()
</code></pre> | python|sql|pandas | 1 |
357,949 | 63,244,545 | How to show sum of data in folium featuregroups | <p><strong>What I want to do:</strong></p>
<p>I want to show the sum of the selected data in the map. So if I check data2, data4 and data5, it'd show me the sum of these dataframes in the markers.</p>
<p><strong>What it does now:</strong></p>
<p>Now when I check data2, data4 and data5, it'll just show me the bottom one... | <p>Changed a few things</p>
<ol>
<li>using <code>map</code> as a variable name. <code>map</code> is a key function in core Python</li>
<li>there's no need for so many separate hits on dataframe with <code>iloc</code> just loop over data you need</li>
<li>excluded points where value is zero. I assume you don't really w... | pandas|folium|choropleth | 0 |
357,950 | 63,098,911 | About overlapping of Time Series on X-axis | <p>I have plotted the timeseries of 5 min on x-axis but it's getting overlapped. Can you suggest the updates to be made?
given below is my output</p>
<p><a href="https://i.stack.imgur.com/hwoJv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwoJv.png" alt="enter image description here" /></a></p>
<p... | <p>Try using this:</p>
<pre><code>plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')
fig.tight_layout()
# you can play around with rotation.
</code></pre>
<p>Second way:</p>
<pre><code>fig.autofmt_xdate()
</code></pre> | python|pandas|matplotlib|data-science | 0 |
357,951 | 63,114,136 | Python long format: subtract selection of rows | <p>All,</p>
<p>I have the following long format dataframe:</p>
<pre><code>df = pd.DataFrame({'date': ["2020-01-01","2020-01-01","2020-01-02","2020-01-02","2020-01-01","2020-01-01","2020-01-02","2020-01-02"], 'asset': ["x", "x... | <p><strong>Use:</strong></p>
<pre><code>m = df['type'].eq('price') & df['asset'].isin(['x', 'y'])
d = df[m].pivot('date', 'asset', 'value').astype(float)
d = pd.concat(
[df, d['x'].sub(d['y']).reset_index(name='value').assign(
asset='x_min_y', type='pricediff')],
ignore_index=True)
</code></pre>
<h... | python|pandas|dataframe|subtraction | 2 |
357,952 | 63,024,842 | How to assign labels/score to data using machine learning | <p>I have a dataframe made by many rows which includes tweets. I would like to classify them using a machine learning technique (supervised or unsupervised).
Since the dataset is unlabelled, I thought to select a few rows (50%) to label manually (+1 pos, -1 neg, 0 neutral), then using machine learning to assign labels ... | <p>I'll propose the sentence or tweet in this context to be analysed for polarity. This can be done using the <code>textblob</code> library. It can be installed as <code>pip install -U textblob</code>. Once the text data polarity is found, it can be assigned as a separate column in the dataframe. Subsequently, the sent... | python|pandas|machine-learning|sentiment-analysis | 6 |
357,953 | 63,127,251 | Plotting more than 10K data point using Seaborn for x-axis as timestamp | <p>I am trying to plot more than 10k data points, where I want to plot a data properties versus Timestamp. But on the x-axis the timestamps are overlapping and not visible.</p>
<p>How can I reduce the amount of labels on the x-axis, so that they are legible?</p>
<pre><code>import pandas as pd
import seaborn as sns
impo... | <p>Update:TIMESTAMP was in string format by converting into datetime format it resolves the problem.</p>
<pre><code>data['TIMESTAMP'] = pd.to_datetime(data['TIMESTAMP'])
</code></pre> | python|pandas|matplotlib|seaborn | 1 |
357,954 | 63,238,560 | Numpy: How to find the most frequent nonzero values in array? | <p>Suppose I have a numpy array of shape <code>(1,4,5)</code>,</p>
<pre><code>arr = np.array([[[ 0, 0, 0, 3, 0],
[ 0, 0, 2, 3, 2],
[ 0, 0, 0, 0, 0],
[ 2, 1, 0, 0, 0]]])
</code></pre>
<p>And I would like to find the most frequent non-zero value in the array ... | <p>We can use <a href="https://numpy.org/doc/stable/reference/generated/numpy.apply_along_axis.html" rel="nofollow noreferrer">numpy.apply_along_axis</a> and a simple function to solve this. Here, we make use of <a href="https://numpy.org/doc/stable/reference/generated/numpy.bincount.html" rel="nofollow noreferrer">num... | python|arrays|numpy | 2 |
357,955 | 62,955,273 | Convolve array with kernel of variable standard deviation | <p>Good day to you fellow programmer !<br />
Today I would like to do something that I believe is tricky. I have a very large 2D array called <code>tac</code> that basically contains time curve values and a file containing a tuple of coordinates called <code>coor</code> which contains information on where to place thes... | <p>Essentially, you have a 4D dataset, shape <code>(nx, ny, nz, nt)</code> that is sparse in <code>(nx, ny, nz)</code> and dense in the <code>nt</code> axis. If <code>(i, j, k)</code> are coordinates of nonzero points in the sparse dimensions, you want to convolve with a Gaussian 3D kernel that has a sigma that depends... | python|numpy|scipy|convolution | 0 |
357,956 | 63,272,687 | Unable to install Pytorch in Ubuntu | <p>I'm using the following command to install pytorch in my conda environment.</p>
<pre><code>conda install pytorch=0.4.1 cuda90 -c pytorch
</code></pre>
<p>However, I'm getting the following error</p>
<blockquote>
<p>Solving environment: failed</p>
<p>PackagesNotFoundError: The following packages are not available fro... | <p>Go directly to the pytorch website and follow the instructions for your setup and it will tell you exactly the command required to install - <a href="https://pytorch.org/get-started/locally/" rel="nofollow noreferrer">pytorch - get started</a></p>
<p>For example:</p>
<p><a href="https://i.stack.imgur.com/D5XqP.png" ... | python|linux|anaconda|pytorch|conda | 2 |
357,957 | 63,149,874 | Return the index from ordinal position pandas dataframe | <p>I have searched for this question but cannot find what I am sure to be a simple answer.</p>
<p>I have a dataframe,</p>
<pre><code>data
Out[77]:
Energy Supply ... Pop Estimate
Country ...
United States 9.083800e+10 ... 2.597967e+13
China ... | <p>An alternative could be:</p>
<pre><code>data.sort_values("Pop Estimate",ascending=False).iloc[2,:].name
</code></pre> | python|pandas|indexing | 1 |
357,958 | 63,005,165 | pip: no matching distribution found for tensorflow | <p><a href="https://i.stack.imgur.com/DhGZ3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DhGZ3.jpg" alt="enter image description here" /></a>
Although I tried hard, I couldn't solve the problem. I can not give any other details because I do not know the reason. If you are curious about a detail, a... | <p>Tensorflow only works on 64 bit systems, so you might want to upgrade your computer</p>
<p>If that's not the problem, try doing</p>
<pre><code>pip install --upgrade pip
</code></pre> | python|tensorflow|pip | 2 |
357,959 | 63,239,676 | How to get histogram data from a 2D NumPy array? | <p>Can <code>numpy.histogram()</code> process a 2D NumPy array? I can't seem to get it to work? In the example below, I am expecting the <code>numpy.histogram()</code> function to return a 3x2 where the 2 denotes a tuple with 2 1D numpy array of size 20 contain the necessary count and bins data, respectively.</p>
<p><s... | <p>A possible way to avoid a for loop would consist in defining a wrapper for <code>np.histogram()</code>:</p>
<pre class="lang-py prettyprint-override"><code>def wrapper(arr):
h, _ = np.histogram(arr, bins=np.linspace(-3, 3, num=7))
return h
</code></pre>
<p>and passing that wrapper function to <a href="https:... | python|numpy | 0 |
357,960 | 63,287,744 | Using a loop function to filter a dataframe into a list of dataframes | <p>I have a small dataframe, two columns wide. My goal is to split this dataframe into a list of dataframes, based on unique values from the QE column.</p>
<p>I can't seem to locate the error in my code.</p>
<p>Edited for clarity:</p>
<pre><code>import pandas as pd
def Function1():
data = {'Name': ['Dave', 'Sue', ... | <p>use a list comprehension and groupby</p>
<pre><code>dfs = [dataframe for _, dataframe in df.groupby('QE')]
print(dfs)
[ Name QE
3 Dave 03.31.2020
4 Michael 03.31.2020
5 Sue 03.31.2020, Name QE
0 Dave 12.31.2019
1 Sue 12.31.2019
2 John 12.31.2019]
</code></pre>
<... | python|pandas|for-loop | 5 |
357,961 | 63,079,625 | Python XML Parse and getElementsByTagName | <p>I was trying to parse the following xml and fetch specific tags that i'm interested in around my business need. and i guess i'm doing something wrong. Not sure how to parse my required tags?? Wanted to leverage pandas, so that i can further filter for specifics. Apprentice all the support</p>
<p><strong>My XMl comin... | <p>Another method.</p>
<pre><code>from simplified_scrapy import SimplifiedDoc, utils, req
# html = req.get('http://couponfeed.synergy.com/coupon?token=xxxxxxxxx122b&network=1&resultsperpage=500')
html = '''
<couponfeed>
<TotalMatches>1459</TotalMatches>
<TotalPages>3</TotalPages>... | python|xml|pandas | 2 |
357,962 | 68,003,864 | How can I make spaCy matches case Insensitive | <p>How can I make spaCy case insensitive?</p>
<p>Is there any code snippet that i should add or something because I couldn't get entities that are not in uppercase?</p>
<pre><code>import spacy
import pandas as pd
from spacy.pipeline import EntityRuler
nlp = spacy.load('en_core_web_sm', disable = ['ner'])
ruler = nlp.a... | <p>As long as it's okay if <code>LOWER</code> is used for all patterns, you can continue to use phrase patterns and add the <code>phrase_matcher_attr</code> option for the entity ruler. Then you don't have worry about tokenizing the phrases and if you have a lot of patterns to match, it will also be faster than using t... | python|pandas|nlp|spacy | 4 |
357,963 | 67,863,947 | How to loop through a pandas dataframe to run an independent ttest for each of the variables? | <p>I have a dataset that consists of around 33 variables. The dataset contains patient information and the outcome of interest is binary in nature. Below is a snippet of the data.</p>
<p>The dataset is stored as a pandas dataframe</p>
<pre><code>df.head()
</code></pre>
<pre><code>ID Age GAD PHQ Outcome
1 23... | <p>You are almost there. <code>ttest_ind</code> accepts multi-dimensional arrays too:</p>
<pre class="lang-py prettyprint-override"><code>cols = ['Age', 'GAD', 'PHQ']
cond = df['outcome'] == 0
neg_outcome = df.loc[cond, cols]
pos_outcome = df.loc[~cond, cols]
# The unequal parameter is invalid so I'm leaving it out
t... | python|pandas|scipy|t-test | 1 |
357,964 | 67,796,493 | Keras error with captured frames when calling predict with frames from game | <p>I am using SerpentAI library to capture a game frame, build a frame stack and feed it to Keras library for predict function.
When doing this, value error occurs</p>
<p>Here's me creating a frame stack:</p>
<pre><code>full_game_frame = FrameGrabber.get_frames(
[0],
frame_shape=(960, 600),
frame_type="... | <p>You still have a problem in your dimensions. As the Error says the expected input is of shape (None, 960, 600, 4) whereas you try to pass an array with shape (1, 600, 960, 4).</p>
<p>Switching dimensions 1 and 2 (basically just a rotation of the image) should remove the error.</p>
<p>Additionally I don't see the nec... | python|tensorflow|keras | 0 |
357,965 | 67,756,325 | Pandas: Query DF based on number of instances taken place with conditions | <p>I have a df containing AirBnB data. There is one question I am stuck trying to answer. The column of interest, <code>host_listings_count</code> contains data of the number of listings each host has.</p>
<p>This is my first attempt querying using Pandas. I would like to know:</p>
<p><strong>The number of hosts that o... | <p>What you can do is first calculate all the unique values over your <code>host_listings_count</code> column and exclude the ones you don't want. In your case that's only filtering for more than 1 property. You can then sort this list and use it as index on your value_counts output like so:</p>
<pre><code>sorted_value... | python|pandas | 1 |
357,966 | 67,911,086 | how to calculate slop and do operations between multiindex dataframe? | <p>I have this dataframe</p>
<pre><code> Name Op A B C
Ob1 L 1 2 3
F 2 4 6
Ob2 L 4 5 6
F 8 10 12
</code></pre>
<p>where Name y Op are index and subindex, but I have to do some operation between multiindex rows like, multiply them: <code>Mult=L*F</cod... | <p>One option would be to take some cross sections <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.xs.html#pandas-dataframe-xs" rel="nofollow noreferrer"><code>xs</code></a> to do the operations with:</p>
<pre><code>mult_df = df.xs('L', 0, 'Op').mul(df.xs('F', 0, 'Op'))
</code></pre... | python|pandas|dataframe|indexing | 0 |
357,967 | 67,759,989 | Find current active connections given connection and disconnection times of a location | <p>I have a dataframe that has <strong>connection date</strong>, <strong>disconnection date</strong>, <strong>rowID</strong> and <strong>RouterName</strong>. I want to find the current active connections in a while loop which iterates every minutes(this can be changed to any minutes) for 24 hours. I am trying to calcul... | <p>I’m going to make a few assumptions:</p>
<ol>
<li><p>every device Id is unique and there are no collisions</p>
</li>
<li><p>you are looking only for devices which are currently connected</p>
</li>
<li><p>a connected device has a null disconnect_at</p>
<p>active = df[df.disconnect_at < curr_timestamp]
counts = act... | python|algorithm|pandas-timeindex | 0 |
357,968 | 67,747,543 | Sum dataframe columns in a loop based on column id | <p>My input dataframe looks something like this.</p>
<pre><code>EXP 1 EXP 2 EXP 3 EXP 4
1 2 4 3
5 6 4 3
5 2 1 2
3 3 2 3
</code></pre>
<p>I want to create three new columns.
The first new c... | <p>Try <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.window.expanding.Expanding.sum.html" rel="nofollow noreferrer"><code>expanding sum</code></a> on axis=1:</p>
<pre><code>sums = df.expanding(axis=1, min_periods=2).sum().iloc[:, 1:]
sums.columns = map(lambda x: f'{df.columns[0]}-{x}',... | python|pandas | 0 |
357,969 | 67,827,101 | I'm trying to compare mean of the company volume with daily volume of the same company and find the difference in pandas. I've made groupby on company | <p><strong>I'm trying to compare mean of the company volume with daily volume of the same company and find the difference in pandas. I've made groupby on company and got mean of each company volume. I want the mean to compare to daily volume of same company.</strong></p>
<p>The code below is :</p>
<pre><code>vol_grp.me... | <p>So I created this sample df</p>
<pre><code>from datetime import datetime as dt
import pandas as pd
from numpy.random import randint
df = pd.DataFrame(dict(date= [dt(2021,1,i) for i in [1]*4+[2]*4+[3]*4],
company= ["AAPL", "FB", "NVDA", "AMZN"]*3,
... | python|pandas|dataframe|for-loop|pandas-groupby | 3 |
357,970 | 67,708,590 | Including minutes column in CSV breaks date parsing | <h4>Problem</h4>
<p>I have a CSV file with components of the date and time in separate columns. When I use <code>pandas.read_csv</code>, I can use the <code>parse_date</code> kwarg to combine the components into a single datetime column <em>if I don't include the minutes column</em>.</p>
<h4>Example</h4>
<p>Consider th... | <p>I'm not sure why just adding on the <code>minutes</code> column for datetime parsing isn't working. But you can specify a function to parse them like so:</p>
<pre class="lang-py prettyprint-override"><code>from io import StringIO
import pandas
data = """\
GAUGE,YEAR,MONTH,DAY,HOUR,MINUTE,PRECIP
1,20... | python|pandas|csv | 3 |
357,971 | 67,711,659 | Adding new calculated columns in pandas data frame | <p>Assume I have a small data frame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
[
["A", 28, 726, 120],
["B", 28, 1746, 250],
["C", 543, 15307, 4500]
],
columns = ["case", "x", "y", ... | <p>Try:</p>
<pre class="lang-py prettyprint-override"><code>df[["x_pctr", "y_pctr", "z_pctr"]] = (
df.loc[:, "x":].div(df.sum(axis=1), axis=0) * 100
).round()
print(df)
</code></pre>
<p>Prints:</p>
<pre class="lang-none prettyprint-override"><code> case x y z x_... | python|python-3.x|pandas | 0 |
357,972 | 67,722,962 | Splitting objects of different lengths in panda series | <p>Python/pandas beginner here.</p>
<p>I have a pandas series (column of a larger df), what looks like this:</p>
<pre><code>0 ['0344010000122413']
1 ['0344010000132886']
2 ['0344010000021642']
3 ['0344010000010731... | <p>You can apply <code>ast.literal_eval</code> and then <code>int()</code> inside list comprehension:</p>
<pre class="lang-py prettyprint-override"><code>from ast import literal_eval
df["NUMPOINTS"] = df["NUMPOINTS"].apply(
lambda x: [int(value) for value in literal_eval(x)]
)
print(df)
</code>... | python|pandas|list|object | 0 |
357,973 | 67,970,519 | What does Tensorflow LSTM return? | <p>I'm writing a German->English translator using an encoder/decoder pattern, where the encoder connects to the decoder by passing the state output of its last LSTM layer
as the input state of the decoder's LSTM.</p>
<p>I'm stuck, though, because I don't know how to interpret the output of the encoder's LSTM. A sma... | <p>An LSTM cell in Keras gives you three outputs:</p>
<ul>
<li>an output state <code>o_t</code> (1st output)</li>
<li>a hidden state <code>h_t</code> (2nd output)</li>
<li>a cell state <code>c_t</code> (3rd output)</li>
</ul>
<p>and you can see an LSTM cell here:
<a href="https://i.stack.imgur.com/Qwt11.png" rel="noref... | python|tensorflow|lstm | 9 |
357,974 | 67,637,508 | Keep the existing columns and convert the row to column | <p>There are three columns in a dataFrame Ticker, Attribute, and Value.</p>
<p><a href="https://i.stack.imgur.com/tNSkc.png" rel="nofollow noreferrer">The original dataFrame can be seen here</a></p>
<p>I want to set the Attribute values as a column which can easily be done by setting it as an index and then taking the ... | <p>Example dataframe:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({
'Ticker': list('AAAAABBBB'),
'Key': list('112341234'),
'Value':list('ZQWERQWER')
})
</code></pre>
<p>To deal with duplicates group by your index and key and aggregate your groups in any way you like. Here I use fir... | python|pandas|dataframe|dataset|data-science | 0 |
357,975 | 67,654,775 | Explode rows with predefined lists while keeping the values for existing rows | <p>I'm struggling with exploding the rows with predefined lists while keeping the values for existing rows.</p>
<p>I have a dataframe like this:</p>
<pre><code>df = pd.DataFrame({'id': ['01','01','02'],
'color': ['red', 'yellow','yellow'],
'wave': ['1', '2', '2'],
... | <pre><code>from itertools import product
# create an expand of all combinations of color and wave
expand = list(product(df.id.unique(), ls_color, ls_wave))
expand
[('01', 'yellow', '1'), ('01', 'yellow', '2'), ('01', 'red', '1'), ('01', 'red', '2'), ('01', 'blue', '1'), ('01', 'blue', '2'), ('02', 'yellow', '1'), ('02... | python|pandas|explode | 2 |
357,976 | 68,020,014 | Conversion of row elements in a column in pandas dataframe | <p>Problem :</p>
<pre><code> df['bua']
0 Built-up Area 97 Sq Yards
1 Built-up Area 85 Sq Yards
2 Built-up Area 80 Sq Yards
3 Built-up Area 100... | <p>To remove the "Built-up Area", use the string method of pandas series:</p>
<pre><code>df['bua'] = df['bua'].str.replace('Built-up Area', '')
</code></pre>
<p>Next, you should convert from yards to feet, but only where, it has yards as a postfix. Again use the pandas str method to split the strings at 'sq '... | pandas|dataframe | 0 |
357,977 | 67,635,753 | I'm trying to mask a date in pandas, before and after | <p>I was able to mask before and after the election date-time into a bool, but when I try to print the df, it returns a key error for the mask</p>
<pre><code>election= dt.datetime(2021, 11, 8)
maskA = df['created_at'] >= election
maskB = df['created_at'] <= election
df['maskA']
</code></pre> | <p>Have you tried the following?</p>
<pre><code>election= dt.datetime(2021, 11, 8)
maskA = df['created_at'] >= election
maskB = df['created_at'] <= election
df[maskA]
</code></pre>
<p>It returns a key error for the mask, because when you call <code>df['maskA']</code>, you are asking for a column with name <code>'... | python|pandas|dataframe|datetime|mask | 0 |
357,978 | 68,002,126 | Azure ML Notebook: Tensorflow does not detect CUDA GPU | <p>I am creating an ML pipeline using Microsoft's Azure Notebooks. I have been having a lot of trouble using CUDA with Tensorflow, I just cannot seem to connect it to the GPU. The problem is that:</p>
<p><code>tf.test.gpu_device_name()</code> returns <code>''</code></p>
<p>Even if all other indicators seem to be indica... | <p>According to <a href="https://www.tensorflow.org/install/source_windows#gpu" rel="nofollow noreferrer">Tensorflow</a> for <code>Tensorflow 1.15.0</code> the compatible <code>CUDA</code> version is <code>10</code>.</p>
<p>Due to incompatibility between them, you get <code>''</code> when you have tried with <code>tf.t... | python|tensorflow | 0 |
357,979 | 67,712,273 | How can I add "sub" dataframes or subrows in Pandas Python with different operation per row and per object? | <p>I have this DataFrame:</p>
<pre><code>>>> data = [['Ob01',1,2,3],['Ob02',4,5,6],['Ob03',7,8,9]]
>>> dfr = pd.DataFrame(data, columns = ['Name', 'A','B','C'])
</code></pre>
<p>dfr</p>
<pre><code> Name A B C
0 Ob01 1 2 3
1 Ob02 4 5 6
2 Ob03 7 8 9
</code></pre>
<p>My problem is that I... | <p>A <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.melt.html#pandas-dataframe-melt" rel="nofollow noreferrer"><code>melt</code></a> + <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.pivot.html#pandas-dataframe-pivot" rel="nofollow noreferrer"><code>pivot</code></a> + <a ... | python|pandas | 0 |
357,980 | 67,728,785 | How to avoid overflow in calculation matrix determinant with large elements | <p>I am going to calculate the determinant of a random 2D-matrix (G) in Python. The matrix is of size about 30 by 30, where each element is chosen randomly from a large prime field with characteristic P using <code>random.randrange(0,P)</code> (e.g. <code>P= 2^160 - 47</code>). The problem is that when I use det comman... | <p>NumPy is not the right tool for this. You need a library that can handle arbitrarily large integers. One option is <a href="https://docs.sympy.org/latest/index.html" rel="nofollow noreferrer">SymPy</a>. SymPy even has the function <a href="https://docs.sympy.org/latest/modules/matrices/matrices.html#sympy.matrice... | python|numpy|scipy|overflow | 1 |
357,981 | 67,753,293 | How to build a heatmap? | <p>I want to build a heatmap where on Y-axis will be number of trees, on X number of leafs, and in the center auc-roc
Here is my code</p>
<pre><code>df = pd.DataFrame(store,columns = ['n_trees' , 'n_leafs', 'auc-roc'])
df.set_index(['n_trees'], inplace=True)
ax = sns.heatmap(df)
</code></pre>
<p>My dataframe looks lik... | <p>You need to pivot your data into a long format, using an example dataset:</p>
<pre><code>import pandas as pd
import seaborn as sns
import numpy as np
np.random.seed(111)
df = pd.DataFrame({'n_trees':np.repeat([10,159,1202,1305],3),
'n_leafs':[1,3,5]*4,
'auc-roc':np.random.unifor... | python|pandas|seaborn|heatmap | 2 |
357,982 | 67,922,378 | Plot and return points of Intersection between two curves plotted from dataframes | <p>I am kind of new to coding and am currently trying to figure out how to find out the point of intersection of two curves plotted from dataframes.</p>
<p>The curves are:</p>
<p><a href="https://i.stack.imgur.com/FQVsx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FQVsx.png" alt="here" /></a></p>... | <p>You can define two new curves. One will be given by the pointwise minimum of your two curves, the other will be a horizontal line at zero. Now, you can use the <code>fill_between</code> method from <code>matplotlib</code>. Here is an example:</p>
<pre><code>xs = np.linspace(0, 10, 100)
ys = -xs**2 - 4 + 10*xs
df = ... | python|pandas|dataframe|intersection|curve | 0 |
357,983 | 67,885,441 | Python Telethon: Scrape and store Telegram messages | <p>I used to code in R, but have recently switched back to Python. For a research project about hate speech, I like to display and store messages from Telegram channels with telethon in a dataframe. I need to store the data because I want to visualise and analyse it computationally. I am used to pandas dataframes, but ... | <p>Your question is more about Python and Pandas than Telegram and Telethon, as far as I can understand.</p>
<pre><code>from telethon.sync import TelegramClient
name = 'anon'
api_id = 'myAPI_ID'
api_hash = "myAPI_hash"
chat = 'chat_link'
async with TelegramClient(name, api_id, api_hash) as client:
asy... | python|pandas|telegram|telethon | 1 |
357,984 | 67,885,492 | Replacing numpy element that are not finite | <p>I have a numpy array with non finite elements. For example :</p>
<pre><code>myMax = np.finfo(float).max
myArray = np.array((0,1,myMax*2))
</code></pre>
<p>I would like to replace non finite element with <code>myMax</code>.</p>
<p>The following instruction does not work :</p>
<pre><code>myArray[not np.isfinite(myArra... | <p>You should use the bitwise NOT (<code>~</code>):</p>
<pre><code>myArray[~np.isfinite(myArray)] = myMax
</code></pre>
<p>Example:</p>
<pre><code>>>> import numpy as np
>>> myMax = np.finfo(float).max
>>> myArray = np.array((0,1,myMax*2))
<stdin>:1: RuntimeWarning: overflow encountered... | python|numpy | 1 |
357,985 | 67,686,039 | ValueError: Could not find matching function to call loaded from the SavedModel and 'CheckpointLoadStatus' object has no attribute 'predict' | <p>I am working on categorizing reviews into multiple labels and built a multi-label text classifier by referring to this <a href="https://github.com/Moradnejad/Bert-Based-Tag-Recommendation/blob/main/tag-recommendation.ipynb" rel="nofollow noreferrer">code</a>. The classification model is based on the Bert text model.... | <p>I was able to solve my issue. I haven't built the model before loading the weights. Because of that, it didn't initialize layers in the subclassed model and gave the error as <code>'CheckpointLoadStatus' object has no attribute 'predict'</code>. The following code shows how I fixed the issue by applying build() meth... | tensorflow|machine-learning|keras|save|tf.keras | 0 |
357,986 | 67,690,805 | tensorflow_text disables GPU on colab | <p>Yesterday everything was working with the transformer. Now I can not use the GPU provided on colab. This works:</p>
<pre><code>%tensorflow_version 2.x
!pip install -q tensorflow_datasets
!pip install -q tensorflow_text
import tensorflow as tf
import tensorflow_datasets as tfds
#import tensorflow_text as text
print(... | <p>I now enforce the old tensorflow_text version:</p>
<pre><code>!pip install -q tensorflow_text==2.4.1
</code></pre>
<p>This seems to work !</p>
<pre><code>%tensorflow_version 2.x
!pip install -q tensorflow_datasets
!pip install -q tensorflow_text==2.4.1
import tensorflow as tf
import tensorflow_datasets as tfds
imp... | tensorflow|text|google-colaboratory|tensorflow2.0 | 0 |
357,987 | 67,632,949 | Find the x,y coordinates for a specific value in a .csv file with Pandas | <p>I have a .csv with thousands of distinct values. I need to figure out the x and y coordinates for a specific value.</p>
<p>I need to find value 756.243 in the .csv - is there something that will say '756.243 is at coordinates (235,1144)?</p>
<p>Sample Dataframe</p>
<pre><code> col1 col2
0 3 1.355
1 4... | <p>Try <code>np.where</code></p>
<pre><code>i, c = np.where(df == 756.243)
</code></pre> | python|pandas|csv | 1 |
357,988 | 67,815,471 | Training with TF 1.15 on RTX 3090 | <p>During I test several cases, I have some questions.
One of that is "Training with tf 1.15 on RTX 3090".</p>
<p><strong>[MY current environments]</strong></p>
<ol>
<li>python : v3.7.9</li>
<li>tensorflow : v1.15.5</li>
<li>cuda : v11.2</li>
<li>cudnn : v8.1.0</li>
<li>os : window 10</li>
</ol>
<p><em>Can I ... | <p>If you can't upgrade your code base to 2.X TF. You may want to use the nvidia-tensorflow version which is basically a nvidia maintained version of tensorflow 1.15 which is compatible with CUDA >11 (and so on RTX 30 gpus).</p>
<p>You'll find more information here : <a href="https://developer.nvidia.com/blog/accele... | tensorflow | 2 |
357,989 | 68,009,422 | How do I select an excel Column based on the column heading value in Python | <p>I have a python dataframe that i paste into an excel sheet using the following code:</p>
<p>df.to_excel(writer, columns = [Weeknum, Weeknum1, Weeknum2], sheet_name = 'QTY SLS', startrow = 5, startcol = 8, header = False, index = False)</p>
<p>The columns selected in the dataframe weeknum, Weeknum1 and Weeknum2 are i... | <p>You can find the start column like this:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
# Toy dataframe
df = pd.DataFrame(
{
"Week 1": [1, 1, 1],
"Week 2": [2, 2, 2],
"Week 3": [3, 7, 3],
"Week 4": [4, 8, 4],
... | python|excel|dataframe|export-to-excel|pandas.excelwriter | 1 |
357,990 | 67,862,640 | forward min and max in time series | <p>How to get the min and max of a time series data?<br />
I know that the rolling gets the values from the past, however, I want to get the data for the next 3 days.</p>
<pre><code>pip install yfinance
# data
df=yf.download('tsla',start='2015-11-26',end='2021-4-28',interval='1d')
# df['min']=df['Close'].roling(3).m... | <p>You can use <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.rolling.html" rel="nofollow noreferrer"><code>.rolling()</code></a> with parameter <code>center=True</code>, as follows:</p>
<pre><code>df['min'] = df['Close'].rolling(7, center=True).apply(lambda x: x[-3:].min())
</code></... | python|pandas|dataframe | 1 |
357,991 | 67,605,589 | Python/Pandas Str.split returns NAN when there is no split | <p>I have a pandas dataframe with a column 'Target Pool'.
Sometimes this column has one value (the year) and sometimes has e values (the year, the quarter).
I want to split it up in to year and quarter. It works except, that if there is only the year, it returns NAN for the year. How can I split if necessary, and if no... | <p>When there is no whitespace to split over (i.e. with numeric values), <code>split</code> falls back and gives <code>NaN</code>. With a <a href="https://regex101.com/r/cfkQJo/1" rel="nofollow noreferrer">regex</a> (might be more robust but might also be an overkill but here we go), you can <a href="https://pandas.pyd... | python|pandas|split | 0 |
357,992 | 67,940,864 | Creating Python Function to Iterate over List/DataFrame (VIF) | <p>I have a dataset and I want to select the subset of variables with VIF(Variance Inflation Factor) smaller than a certain threshold. My idea was to calculate the VIF for every variable, then take out the variable for the highest value (if its higher than a certain threshold), recalculate the VIF for every remaining v... | <p>Maybe what would make sense is to remove the variable with the highest vif in each round, subset the dataframe and stop when all variables are lower than your threshold. I don't think vif would be be-all-and-end-all and you really have to look at the data to decide what to include etc.</p>
<pre><code>import statsmod... | python|pandas|machine-learning|statistics|statsmodels | 0 |
357,993 | 67,838,481 | Pandas df - Limit results per group | <p>I have this df:</p>
<p><a href="https://i.stack.imgur.com/b2leO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b2leO.png" alt="enter image description here" /></a></p>
<p>I want to limit the number of rows per each group of: attribute_1 & attribute_2.
Limit to 10 rows per group.
As you can se... | <p>You can use <code>groupby</code> and then <code>apply</code> with a <code>lambda</code> to extract only the first few elements that you want. For example:</p>
<pre><code>a = [1]*3 + [2]*3 + [3]*3
b = [*range(0, 3)]*3
c = ['x']*3 + ['y']*3 + ['z']*3
somedf = pd.DataFrame({'a': a, 'b': b, 'c': c})
</code></pre>
<p>In ... | python|pandas | 1 |
357,994 | 67,659,883 | Send column names that contain a certain string to a list in pandas | <p>I have the following dataframe that contains columns like:</p>
<pre><code>df
a b c d a_main b_main c_main d_main
row
row2
row3
</code></pre>
<p>I would like the column names that contain <code>_main</code> sent to a list. such as:</p>
<pre><code>collist = ['a_main' , 'b_main' , 'c_main' , '... | <p>try via <code>filter()</code> method:</p>
<pre><code>collist=df.filter(like='_main').columns.tolist()
</code></pre>
<p><strong>OR</strong></p>
<p>Via boolean masking:</p>
<pre><code>collist=df.columns[df.columns.str.endswith('_main')].tolist()
</code></pre> | python|pandas | 2 |
357,995 | 67,612,288 | Counting duplicate rows entries, RAM efficiently | <p>I have a BIG dataframe and want to get a count of how many there are of each rows.
I have been using this:</p>
<pre><code>df.groupby(df.columns.tolist(), as_index=False, sort=False).size()
</code></pre>
<p>But it requires more than 60GB RAM, while I'm stuck with 32GB.</p>
<p>Then I came up with this, but it is painf... | <p>One of the columns is a categorial / enum column.</p>
<p>It turns out, that by default, Pandas will generate groups for categories even if they don't exist in the data.</p>
<p>The solution is to use <code>observed=True</code>, thus:</p>
<pre><code>counts = df.groupby(df.columns.tolist(), as_index=False, sort=False, ... | python|pandas|pandas-groupby | 2 |
357,996 | 67,866,161 | Joining and comparing values of one df with first value of second df and then cumulative comparison | <p>I have two dataframes according to dates such as:
df1</p>
<pre><code>id date time sum
abc 15/03/2020 01:00:00 15
abc 15/03/2020 02:00:00 25
abc 15/03/2020 04:00:00 10
xyz 15/03/2020 12:00:00 30
xyz 15/03/2020 03:00:00 20
</code></pre>
<p>df2</p>
<pre><code>id date... | <p>Use:</p>
<pre><code>print (df1)
id date time sum sum1
0 abc 15/03/2020 01:00:00 15 10
1 abc 15/03/2020 02:00:00 25 10
2 abc 15/03/2020 04:00:00 10 10
3 xyz 15/03/2020 12:00:00 30 10
4 xyz 15/03/2020 03:00:00 20 10
print (df2)
id date sum sum1
0 ... | python|pandas|merge|pandas-groupby | 0 |
357,997 | 67,796,132 | Searching for words in a CSV file column with str.contains | <p>I have the following csv file:</p>
<pre><code>start_date,end_date,pollster,sponsor,sample_size,population,party,subject,tracking,text,approve,disapprove,url
2020-02-02,2020-02-04,YouGov,Economist,1500,a,all,Trump,FALSE,Do you approve or disapprove of Donald Trump’s handling of the coronavirus outbreak?,42,29,htt... | <p>In your example case all rows contain both keywords, so you should get all five rows returned.</p>
<p>With the function call <code>contains('Trump', 'coronavirus')</code> you get all rows that have 'Trump' OR 'coronavirus' in its text column. To get only columns that contain 'Trump' AND 'coronavirus' you can use the... | python|pandas|string|csv | 2 |
357,998 | 67,956,633 | TypeError: in method 'IndexIDMap_add_with_ids', argument 4 of type 'faiss::IndexIDMapTemplate< faiss::Index >::idx_t const *' | <p><strong>I'm trying to do semantic search with Pre trained bert models and transformers. I'm using Facebook AI library Faiss.</strong></p>
<p>The code is :</p>
<pre><code>encoded_data = model.encode(df.Plot.tolist())
encoded_data = np.asarray(encoded_data.astype('float32'))
index = faiss.IndexIDMap(faiss.IndexFlatIP(... | <p>Faiss <code>add_with_ids()</code> only accepts ids of np.int64 dtype.<br />
I didn't find Python documentation of this data type requirement, but this link <a href="https://faiss.ai/cpp_api/struct/structfaiss_1_1Index.html" rel="nofollow noreferrer">https://faiss.ai/cpp_api/struct/structfaiss_1_1Index.html</a> (alth... | nlp|bert-language-model|huggingface-transformers|sentence | 0 |
357,999 | 67,799,421 | Can I adjust the scale of color bar in this seaborn heatmap? | <p>Here's a dictionary of data I'm trying to visualize:</p>
<pre><code>SPEC1 = {-15.0: 0.2111724739193578,
-14.487179487179487: 0.2394370325685465,
-13.974358974358974: 0.28457460638442267,
-13.461538461538462: 0.3060820977687277,
-12.948717948717949: 0.27936658325947794,
-12.435897435897436: 0.3264169114891287,
... | <p>Have you tried with <code>vmin = 0</code> and <code>vmax = 1</code>?? I think that should work</p> | python|pandas|dataframe|seaborn|colormap | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.