question_id int64 37.6M 73.2M | input_text stringlengths 88 52.4k | output_text stringlengths 37 35.6k | title stringlengths 15 150 | tags stringlengths 1 107 | q_score int64 -19 397 | view_count int64 3 879k | answer_count int64 1 21 | accepted_answer_id int64 37.6M 73.8M | answer_id int64 37.6M 73.8M | a_score int64 -5 1.29k | is_accepted bool 1
class | creation_date stringlengths 20 24 | input_text_instruct stringlengths 251 52.6k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
72,399,746 | How to check the model prediction with original values in machine learning<p>I have trained my model using machine learning and want to check with original value. Is i am doing it right?
As whenever I change the numbers in 'value' getting the same result.</p>
<pre><code>X_train, X_test, y_train, y_test = train_test_spl... | <p>Got the half solution to my problem. I was normalizing the model before fit.</p>
<p>But the original data (value) is not normalize.</p>
<p>Below code works but but now my data which i am using for fit is not normalize.
Any solution?</p>
<pre><code>X_train, X_test, y_train, y_test = train_test_split(df4, y, test_size... | How to check the model prediction with original values in machine learning | python|pandas|machine-learning|data-science|random-forest | 0 | 51 | 2 | 72,399,875 | 72,399,875 | 0 | true | 2022-05-27T02:09:03.140Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to check the model prediction with original values in machine learning<p>I have trained my model using machine learning and want to check with original v... |
72,353,135 | Minizinc seemingly generates invalid FZ code<p>I have the following piece of my model:</p>
<pre><code>constraint forall(d in Day, s in Student)
(
let {
%groups in day
array[int] of var opt Group: gid = [g | g in assignment[s] where group_day[g] == d];
%groups starts in day
array[int] of var opt Time: ... | <p>The problem was solved by patching minizinc.</p>
<p>Issue was handled here:
<a href="https://github.com/MiniZinc/libminizinc/issues/588" rel="nofollow noreferrer">https://github.com/MiniZinc/libminizinc/issues/588</a></p>
<p>After compiling the develop branch, the issue disappeared!</p> | Minizinc seemingly generates invalid FZ code | compiler-errors|constraint-programming|minizinc | 0 | 51 | 1 | 72,402,425 | 72,402,425 | 0 | true | 2022-05-23T18:16:14.287Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Minizinc seemingly generates invalid FZ code<p>I have the following piece of my model:</p>
<pre><code>constraint forall(d in Day, s in Student)
(
let {
... |
72,391,752 | program crash after swapping addresses in x86<p>I want to create two arrays, therefore I use <code>malloc</code> to allocate dynamic storage.</p>
<pre><code> mov rdi, 10
call malloc
mov dl, [rax]
mov [rbx], dl ; <- right here is the problem
call malloc
</code></pre>
<p>But my program doesn't actua... | <p>It is not entirely clear what you are trying to accomplish, but I'm guessing that you want to <code>malloc</code> two arrays and then swap their first elements, judging by your pseudo C and the comments.</p>
<p>As people have pointed out in the comments, your <code>rbx</code> is never set to any actual address, so i... | program crash after swapping addresses in x86 | assembly|x86|malloc | 0 | 51 | 1 | 72,409,154 | 72,409,154 | 0 | true | 2022-05-26T12:22:14.777Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
program crash after swapping addresses in x86<p>I want to create two arrays, therefore I use <code>malloc</code> to allocate dynamic storage.</p>
<pre><code>... |
72,300,318 | How to rename and reorganize file using regex and rename-cli?<p>I have a large amount of article on my blog I want to rename and reorganize.</p>
<p>The current structure is this one:</p>
<pre class="lang-none prettyprint-override"><code>2005_03_19_this_is_the_filename.md
2007_07_23_another_filename.md
2021_01_12_filena... | <p>I manage to it with the following command:</p>
<pre><code>$ rename -p 's~(\d{4})_(\d{2})_\d{2}_(.+)(\.md)$~$1/$2/$3/index.md~' *.md
</code></pre>
<p>Thanks to @anubhava</p> | How to rename and reorganize file using regex and rename-cli? | regex|file-rename|batch-rename | 0 | 51 | 2 | 72,560,563 | 72,560,563 | 0 | true | 2022-05-19T07:25:15.147Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to rename and reorganize file using regex and rename-cli?<p>I have a large amount of article on my blog I want to rename and reorganize.</p>
<p>The curre... |
72,279,317 | My goal is to run a Stepper through Python, but the values such as angular velocity and degrees are inputted by user through GUI<p>I'm having trouble with the Tkinter window not showing its contents and also storing the data inputted by the user into the stepper parameters. I got to run the Tkinter and the stepper in s... | <p>I had to move quite a bit of things around. There may be some issues with this still as I am not familiar with all the context of the original code. However, hopefully it is good enough that you can see how to accomplish your goal.
I looked at the pymata4 module and there are some issues with what you are doing.</p>... | My goal is to run a Stepper through Python, but the values such as angular velocity and degrees are inputted by user through GUI | python|tkinter | 0 | 51 | 1 | 72,280,254 | 72,280,254 | 0 | true | 2022-05-17T18:55:37.617Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
My goal is to run a Stepper through Python, but the values such as angular velocity and degrees are inputted by user through GUI<p>I'm having trouble with th... |
72,365,941 | List index out of range Error in python ,but index is in range how is it?<pre><code>def longestValidParentheses(si):
cnt=0
s=[]
for _ in range(0,len(si)):
s.append(si[_])
print(s[6])
for i in range(0,len(s)-1):
print(i)
if (s[i]=="("):
for j in range(0,len(s)):
... | <p>You have a dynamic variable (len(s)) used as your upper bound on your range. A quick check is to throw a print statement of len(s) after you pop. The first pop occurs early enough that your original loop is still valid, but the second time you pop you have len(s) = 5, and then you try to access s[5] as i is incremen... | List index out of range Error in python ,but index is in range how is it? | python|list|indexing|range | 0 | 51 | 1 | 72,366,247 | 72,366,247 | 0 | true | 2022-05-24T15:54:30.137Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
List index out of range Error in python ,but index is in range how is it?<pre><code>def longestValidParentheses(si):
cnt=0
s=[]
for _ in range(0,... |
72,296,419 | Getting SQL Exception when trying to get the last auto-incremented value<p>I've been trying everything, nothing is working, I'm new to mysql and databases and I want to get the last auto-incremented id (primary key) (<code>user_id</code>) from a table, from java. So this: <code>SELECT MAX(user_id) FROM database_user;</... | <p>You are missing <code>rs.next();</code> between executing the query and fetching from the result set. This is needed, to move the result set to the first row.</p>
<p>You also shouldn't have <code>st.executeUpdate()</code>. Just executing once is enough.</p> | Getting SQL Exception when trying to get the last auto-incremented value | java|mysql | 0 | 51 | 1 | 72,296,437 | 72,296,437 | 0 | true | 2022-05-18T21:53:19.110Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Getting SQL Exception when trying to get the last auto-incremented value<p>I've been trying everything, nothing is working, I'm new to mysql and databases an... |
72,285,956 | How to add value to object and remove current value?<p>I have data like this :</p>
<pre><code>users = [{
"emp_id": 1,
"user": {
"emp_full_name": "Test",
"emp_email": "test@gmail.com",
"emp_phone_no": null,
&quo... | <p>You can use <code>.reduce()</code> with <code>.findIndex()</code>. Try this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let users = '[{"emp_id": 1, "user": {"emp_full_na... | How to add value to object and remove current value? | javascript|object | 0 | 51 | 2 | 72,286,370 | 72,286,370 | 0 | true | 2022-05-18T08:47:29.007Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to add value to object and remove current value?<p>I have data like this :</p>
<pre><code>users = [{
"emp_id": 1,
"user": {
... |
72,336,600 | Convert HTML List to a List with Dropdown Menu<p>I have an HTML list, and I want to create a new list out of it to support dropdown if some items start with <code>-</code>.</p>
<p>It works fine if the list items that start with <code>-</code> are in the middle of the list but not if these items are the latest ones.</p>... | <p>Here's another straight forward approach:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var dropDown_list = [],
latest_navigation_item,
nav_list = document.querySe... | Convert HTML List to a List with Dropdown Menu | javascript|html | 0 | 51 | 2 | 72,337,191 | 72,337,191 | 0 | true | 2022-05-22T10:12:17.503Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Convert HTML List to a List with Dropdown Menu<p>I have an HTML list, and I want to create a new list out of it to support dropdown if some items start with ... |
72,263,706 | How would I define a function for this? [Noob question]<p>I´m working on creating a list for a game I play with my friends where words get added x times to that list.
Currently, I´m using the same three lines of code 5 times and I´d like to instead just call up a predefined funtion 5 times. is that possible? (I only tr... | <p>A bigger sample of your script maybe would have helped, but from my understanding of your script if I had this problem I would do this:</p>
<pre><code>def fruitFunction(fruit, newList):
amountFruit = int(input(f"How many {fruit}?"))
for amount in range(amountFruit):
newList.append(fruit)
... | How would I define a function for this? [Noob question] | python | 0 | 51 | 2 | 72,263,886 | 72,263,886 | 0 | true | 2022-05-16T18:05:45.260Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How would I define a function for this? [Noob question]<p>I´m working on creating a list for a game I play with my friends where words get added x times to t... |
72,390,436 | list index out of range when appending data in CSV file<p>I have a CSV file in which I have data in three columns and I want to add new rows after checking the data exists then want to add these data in new rows but getting the error <code>list index out of range</code></p>
<p>this is my code</p>
<p>Categories</p>
<pre... | <p>The main issue with the original solution was handling the file. The outer <code>for</code> loop wouldn't stop, since the inner for loop was appending line to the working file.</p>
<p>Here, I used a simple list to store what needs to be duplicated. If the file is too large, another option would be to use <strong>a s... | list index out of range when appending data in CSV file | python|csv | -3 | 51 | 1 | 72,391,211 | 72,391,211 | 0 | true | 2022-05-26T10:35:29.303Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
list index out of range when appending data in CSV file<p>I have a CSV file in which I have data in three columns and I want to add new rows after checking t... |
72,265,604 | Javascript to generate dynamic clip-path for svg<p>I am working with a svg element which is as follows</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><co... | <p>This worked for me</p>
<pre><code>const svgns = 'http://www.w3.org/2000/svg';
document.querySelectorAll('.tick>line').forEach(
(a,i)=>{
const defs = document.createElementNS(svgns, 'defs');
document.querySelector('svg').appendChild(defs);
const clipPath = document.createElementNS(s... | Javascript to generate dynamic clip-path for svg | javascript|svg | 0 | 51 | 1 | 72,266,086 | 72,266,086 | 0 | true | 2022-05-16T21:03:16.183Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Javascript to generate dynamic clip-path for svg<p>I am working with a svg element which is as follows</p>
<p><div class="snippet" data-lang="js" data-hide="... |
72,298,690 | Laravel check if belongstomany contains belongstomany<p>in my system:</p>
<ul>
<li>a lead belongstomany salespeople</li>
<li>a manager belongstomany salespeople</li>
</ul>
<p>i am trying to check if a lead has a manager through the salespeople. this is for a policy so i can make sure a manager can see the leads of thei... | <p>Ended up solving this problem with this package: <a href="https://github.com/staudenmeir/eloquent-has-many-deep" rel="nofollow noreferrer">https://github.com/staudenmeir/eloquent-has-many-deep</a></p>
<p>Here's my relationship method now:</p>
<pre><code>public function managers()
{
return $this->hasManyDeepFr... | Laravel check if belongstomany contains belongstomany | php|laravel|collections|relationship | 0 | 51 | 1 | 72,300,660 | 72,300,660 | 0 | true | 2022-05-19T04:34:55.017Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Laravel check if belongstomany contains belongstomany<p>in my system:</p>
<ul>
<li>a lead belongstomany salespeople</li>
<li>a manager belongstomany salespeo... |
72,274,727 | Style for 2 line header<p>i have a html table with two lines as header. I use the second row for a filter drop down. so it is empty in the table itself.</p>
<pre class="lang-html prettyprint-override"><code> <table class="tg wrap stripe" id="tableData">
<thead>
<... | <p>Here you are having several lack:</p>
<ul>
<li>You must add border to <code>th</code> not the <code>tr</code></li>
<li>You must add the type of line you want and the color</li>
</ul>
<p>You tried wrong css path here:</p>
<pre class="lang-css prettyprint-override"><code>.tg tr thead:last-child{
border-bottom: 1px;... | Style for 2 line header | css|html-table|tableheader | 0 | 51 | 1 | 72,275,203 | 72,275,203 | 0 | true | 2022-05-17T13:14:14.867Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Style for 2 line header<p>i have a html table with two lines as header. I use the second row for a filter drop down. so it is empty in the table itself.</p>
... |
72,332,837 | Menu content display issue<p>I need some help pls. I created a menu with section and courses; but the section-labels are repeating.</p>
<p>I would like all courses with the same section to be displayed on a single section lable.</p>
<p>Please see code and screenshot.</p>
<pre><code><Menu
... | <p>You need to group the lessons by section, then you must iterate over each lessons in the section.</p>
<p>Here is a possible solution :</p>
<pre class="lang-js prettyprint-override"><code>// group lessons by section into an object {sectionName: [lesson1, lesson2]}
const lessonsBySection = course.lessons.reduce(functi... | Menu content display issue | javascript|reactjs|menu|antd|menuitem | 0 | 51 | 1 | 72,333,027 | 72,333,027 | 0 | true | 2022-05-21T20:00:12.753Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Menu content display issue<p>I need some help pls. I created a menu with section and courses; but the section-labels are repeating.</p>
<p>I would like all c... |
72,316,365 | Snowflake's time difference alternative to Postgres INTERVAL<p>I have UNIX duration in ms, that needs to be converted to human readable format. In Postgres it is possible to do using INTERVAL type, but how can it be done in Snowflake? The challenge is that some of those values can exceed 24h. I've checked solution to a... | <pre><code>select *
,floor(ms/3600000) as hh
,floor((ms%3600000)/60000) as mm
,floor((ms%60000)/1000) as ss
,nullifzero(hh) as a1
,nullifzero(mm) as a2
,nullifzero(ss) as a3
,trim(nvl(a1||'h ','') || nvl(a2||'m ','') || nvl(a3||'s','')) as r
from values
(7200000, '2h'),
(28800000 , ... | Snowflake's time difference alternative to Postgres INTERVAL | snowflake-cloud-data-platform | 0 | 51 | 2 | 72,317,867 | 72,317,867 | 0 | true | 2022-05-20T09:10:38.980Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Snowflake's time difference alternative to Postgres INTERVAL<p>I have UNIX duration in ms, that needs to be converted to human readable format. In Postgres i... |
72,286,925 | Question about the syntax of a function in Node.js<p>I am following a tutorial to make a blog, and for the MongoDB connection in the server.js file, the instructor made a boiler connection function <strong>withDB</strong>. Operations and res are props of withDB function. In line 6, is operations a function passed a pro... | <p>yes actually <code>operations</code> is your callback function, you call it with db as param once you initialize your database connection.</p>
<p>Maybe you're not comfortable with ES6 arrow function syntax. you can find in <a href="https://developer.mozilla.org/en-US/docs/Glossary/Callback_function" rel="nofollow no... | Question about the syntax of a function in Node.js | node.js|backend | 1 | 51 | 1 | 72,297,552 | 72,297,552 | 0 | true | 2022-05-18T09:53:54.063Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Question about the syntax of a function in Node.js<p>I am following a tutorial to make a blog, and for the MongoDB connection in the server.js file, the inst... |
72,240,939 | Is there a simple way to compare two class objects for all items that are not none?<p>I am looking to compare two instances of the same class, but only the items for which both are not <code>None</code>.</p>
<p>for instance,</p>
<p>I will have a <code>Bolt</code> class, and one instance will have:</p>
<pre><code>bolt1.... | <p>I would just keep it simple:</p>
<pre class="lang-py prettyprint-override"><code>class Bolt:
# ...
def __eq__(self, other):
if [self.locx, self.locy, self.locz] != [other.locx, other.locy, other.locz]:
return False
if self.rpid is not None && other.rpid is not None &&... | Is there a simple way to compare two class objects for all items that are not none? | python|list|class|dictionary|list-comprehension | 0 | 51 | 3 | 72,240,980 | 72,240,980 | 1 | true | 2022-05-14T14:02:19.457Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there a simple way to compare two class objects for all items that are not none?<p>I am looking to compare two instances of the same class, but only the i... |
72,245,440 | How with faker to get text without ending “.”?<p>When in laravel 9 app I set value for text field with faker :</p>
<pre><code> $this->faker->unique()->text(25);
</code></pre>
<p>I see text for field ending with “.”.
How can I get text without ending “.” ?</p>
<pre><code>"laravel/framework": "^9.... | <p>The author of the library decided not to implement this feature: <a href="https://github.com/fzaninotto/Faker/issues/1128" rel="nofollow noreferrer">https://github.com/fzaninotto/Faker/issues/1128</a></p>
<p>You can do it like:</p>
<pre><code>substr(str_replace('.', '', $this->faker->unique()->text(25)), 0,... | How with faker to get text without ending “.”? | laravel|faker | 0 | 51 | 1 | 72,245,550 | 72,245,550 | 1 | true | 2022-05-15T04:02:28.517Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How with faker to get text without ending “.”?<p>When in laravel 9 app I set value for text field with faker :</p>
<pre><code> $this->faker->unique()-&... |
72,247,889 | How could this doubly linked list search code be implemented?<p>I got this code which is supposed to provide an algorithm that searches for the item in the middle of a doubly-linked list.
There may be one or more flaws in the code making the code not executable.
How can this code be implemented to make it work using a ... | <p>The problem is you 'step' both nodes at the same time inside the loop.
You can thus miss the middle because they can jump over each other without being detected.</p>
<p>You should step one node at a time in each loop iteration.
The solution could be something like this:</p>
<pre><code>node1 = self.head
node2 = self.... | How could this doubly linked list search code be implemented? | python|doubly-linked-list | 0 | 51 | 3 | 72,248,028 | 72,248,028 | 1 | true | 2022-05-15T11:35:56.783Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How could this doubly linked list search code be implemented?<p>I got this code which is supposed to provide an algorithm that searches for the item in the m... |
72,250,005 | Javascript/Google Apps Script IndexOf issues<p>There are a couple of similar queries here about the IndexOf function, but I'm reaching out because although the answers provided have been helpful, none of them have solved the issue.</p>
<p>I have a (very) large 2d array from a spreadsheet of names vs id codes. I read th... | <p><strong>Description</strong></p>
<p>I've constructed a spreadsheet sheet using the names from the json data file, randomized the names so they are no longer in alphabetical order and then assigned an id number to each.</p>
<p><a href="https://i.stack.imgur.com/wGQQ1.png" rel="nofollow noreferrer"><img src="https://i... | Javascript/Google Apps Script IndexOf issues | javascript|arrays|google-apps-script|indexof | -1 | 51 | 1 | 72,250,702 | 72,250,702 | 1 | true | 2022-05-15T16:10:16.977Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Javascript/Google Apps Script IndexOf issues<p>There are a couple of similar queries here about the IndexOf function, but I'm reaching out because although t... |
72,237,958 | How to include externel user files into UWP side-loading package?<p>Say I use some .json files to descript some object data which effect to the program's behavior, I hope to use these files in the following scenarios</p>
<ol>
<li><p>The default values, for this purpose, I need a set of files follows with the applicatio... | <blockquote>
<p>How to include externel user files into UWP side-loading package?</p>
</blockquote>
<p>You could place the json file into app's project and set the file property as <code>Content</code>, then it will deploy into <a href="https://docs.microsoft.com/en-us/uwp/api/windows.applicationmodel.package.installed... | How to include externel user files into UWP side-loading package? | c#|uwp|winui-3|winui | 0 | 51 | 1 | 72,254,570 | 72,254,570 | 1 | true | 2022-05-14T06:45:59.853Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to include externel user files into UWP side-loading package?<p>Say I use some .json files to descript some object data which effect to the program's beh... |
72,257,029 | Unmatch when Slash( / ) is followed by Underscore( _ ) or hyphen( - )<p>I am constructing an ID, in Javascript, which doesn't allow special character and uppercase letter. We could have <code>/ _ -</code> in the ID, but the it should not begin with these.</p>
<ul>
<li>hello <em>correct</em></li>
<li>helloWorld <em>inco... | <p>You can use</p>
<pre class="lang-none prettyprint-override"><code>^(?=.{1,50}$)[a-z0-9]+(?:[-_\/][a-z0-9]+)*[-_\/]?$
</code></pre>
<p>See the <a href="https://regex101.com/r/PsAbh1/3" rel="nofollow noreferrer">regex demo</a>.</p>
<p><em>Details</em>:</p>
<ul>
<li><code>^</code> - string start</li>
<li><code>(?=.{1,5... | Unmatch when Slash( / ) is followed by Underscore( _ ) or hyphen( - ) | regex | 1 | 51 | 1 | 72,257,211 | 72,257,211 | 1 | true | 2022-05-16T09:32:42.687Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unmatch when Slash( / ) is followed by Underscore( _ ) or hyphen( - )<p>I am constructing an ID, in Javascript, which doesn't allow special character and upp... |
72,263,868 | Pandas groupby filter only last two rows<p>I am working on pandas manipulation and want to select only the last two rows for each column "B".</p>
<h1>How to do without reset_index and filter (do inside groupby)</h1>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
df = pd.DataFrame({
'A... | <p>Try:</p>
<pre><code>df.sort_values(['A', 'B']).groupby(['A']).tail(2)
</code></pre>
<p>Output:</p>
<pre><code> A B V
1 a 1 20
2 a 2 30
3 b 5 40
4 b 7 50
10 c 2 110
7 c 4 80
</code></pre> | Pandas groupby filter only last two rows | python|pandas | 1 | 51 | 2 | 72,264,035 | 72,264,035 | 1 | true | 2022-05-16T18:20:40.753Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Pandas groupby filter only last two rows<p>I am working on pandas manipulation and want to select only the last two rows for each column "B".</p>
<... |
72,271,720 | Single-row subquery returns more than one row for update query | PLSQL |<p>I am bit stuck with this not getting how do I write the code.</p>
<p>I have table called <code>STUDENT</code> with this data in it:</p>
<pre><code>STUDID | NAME | SURNAME | STUDENT_FILE | CLASS
-------+------+---------+------------------... | <p>You don't need PL/SQL, only an ordinary UPDATE:</p>
<pre><code>UPDATE student
SET student_file =
SUBSTR (student_file,
( INSTR (student_file,
'\',
-1,
1)
+ 1),
LENG... | Single-row subquery returns more than one row for update query | PLSQL | | sql|oracle|plsql | 0 | 51 | 1 | 72,271,773 | 72,271,773 | 1 | true | 2022-05-17T09:46:52.040Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Single-row subquery returns more than one row for update query | PLSQL |<p>I am bit stuck with this not getting how do I write the code.</p>
<p>I have table ... |
72,271,894 | ReactJS - Change CSS Class Properties<p>How can we dynamically change the properties of a CSS Class in ReactJS. For example, I have several text fields with CSS Classname "important". I want to change all of them to have flash a red background on click of a button.</p>
<p>I thought I could do this by changing... | <p>In your <code>render()</code> method, use a state variable to attach different classes to the rendered element depending on its state.</p> | ReactJS - Change CSS Class Properties | javascript|css|reactjs | 0 | 51 | 2 | 72,271,947 | 72,271,947 | 1 | true | 2022-05-17T09:57:31.037Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
ReactJS - Change CSS Class Properties<p>How can we dynamically change the properties of a CSS Class in ReactJS. For example, I have several text fields with ... |
72,275,487 | Using different features for the same estimator in the pipeline<p>I have a nice pipeline that does the following:</p>
<pre><code>pipeline = Pipeline([
("first transformer", ct),
("second transformer", OHE),
('standard_scaler', MinMaxScaler()),
("logistic regression", estima... | <p>Since you want (potentially) to use a different subset of features for each output, you should just put the <code>SelectKBest</code> in a pipeline with the <code>LogisticRegression</code> <em>inside</em> the <code>MultiOutputClassifier</code>.</p>
<pre class="lang-py prettyprint-override"><code>clf = Pipeline([
... | Using different features for the same estimator in the pipeline | python|machine-learning|scikit-learn|pipeline|feature-selection | 3 | 51 | 1 | 72,277,406 | 72,277,406 | 1 | true | 2022-05-17T14:05:07.963Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using different features for the same estimator in the pipeline<p>I have a nice pipeline that does the following:</p>
<pre><code>pipeline = Pipeline([
(&... |
72,277,623 | How does spark calculates number of records in a dataframe?<p>I know that df.count() will trigger a spark action and return number of records present in a dataframe, but I wanted to know how this process work internally does spark goes through the whole dataframe to count number of records or is there any other optimis... | <p>It appears that underneath the hood running <code>df.count()</code> actually uses the <a href="https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Count.scala" rel="nofollow noreferrer">Count</a> aggregation class. I am basing this on the defini... | How does spark calculates number of records in a dataframe? | python|apache-spark|pyspark | 1 | 51 | 1 | 72,280,679 | 72,280,679 | 1 | true | 2022-05-17T16:28:37.870Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How does spark calculates number of records in a dataframe?<p>I know that df.count() will trigger a spark action and return number of records present in a da... |
72,279,043 | Stack overflow for huge file with many variables in different scopes<p>I have a autogenerated file creating structs and doing some calculations with them.
Each struct has its dedicated scope.</p>
<pre><code>typedef struct
{
uint16_t a;
uint16_t b;
} Addition_t;
uint8_t StructsOverflow(void)
{
{ // use new... | <p>Why? Because, in a Debug build (IIRC), MSVC doesn't deallocate local variables when they go out of scope in this way. In a Release build, it will probably work.</p>
<p>But what's really broken here, IMO, is whatever it is that autogenerates that file. Would it be practical to change it to generate 100,000 separat... | Stack overflow for huge file with many variables in different scopes | c|visual-studio|stack-overflow | 0 | 51 | 1 | 72,281,316 | 72,281,316 | 1 | true | 2022-05-17T18:30:28.773Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Stack overflow for huge file with many variables in different scopes<p>I have a autogenerated file creating structs and doing some calculations with them.
Ea... |
72,282,312 | Aligning title and y axis labels<p>I've got two charts on top of each other, and I'm looking to align the title and y axis as per screenshot. The title's I've done as a separate textbox as I wasn't happy with the rendering when using the chart title label as the output would look slightly different compared to the text... | <p>You can do this (I just found out!), at least it worked for my simple example.</p>
<p>I took an existing test report with a chart in it, duplicated the chart and then set the Y-Axis values for the second one to be 1000 times higher, in order to force the condition you are seeing.</p>
<p>In the design, both charts ar... | Aligning title and y axis labels | reporting-services | 0 | 51 | 1 | 72,287,656 | 72,287,656 | 1 | true | 2022-05-18T01:30:52.587Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Aligning title and y axis labels<p>I've got two charts on top of each other, and I'm looking to align the title and y axis as per screenshot. The title's I'v... |
72,287,576 | query to get statistic data from SQL server<p>I have a table named total sales. In this table there are sales data like invoice date and branch name that sells the invoice and the quantity.</p>
<p>I am trying to make a query to get total sales for each branch in every single date and my code is below, but when I execut... | <p>Based on your description, what you wanted should be</p>
<pre><code>SELECT invoice_date,
SUM(case when branche_name = 'branch1' then quantity end) AS malqaStore,
SUM(case when branche_name = 'branch2' then quantity end) AS tahliaStore
FROM total_sales
WHERE branche_name in ( 'branch1' , 'branch2' )
... | query to get statistic data from SQL server | sql|sql-server | -2 | 51 | 1 | 72,287,913 | 72,287,913 | 1 | true | 2022-05-18T10:36:05.410Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
query to get statistic data from SQL server<p>I have a table named total sales. In this table there are sales data like invoice date and branch name that sel... |
72,272,442 | Using the pygame function pygame.pixelcopy.surface_to_array()<p>I've been sitting on this for a while now but the documentation is really confusing and has no examples.</p>
<p>I'm trying to store the rgb values of every pixel in a surface. I've tried the following code:</p>
<pre><code>original_pixels = numpy.zeros((wn_... | <p>Your code is almost correct, but by default <a href="https://numpy.org/doc/stable/reference/generated/numpy.zeros.html" rel="nofollow noreferrer"><code>numpy.zeros</code></a> creates an array of <em>floats</em>. However, for use with <a href="https://www.pygame.org/docs/ref/pixelcopy.html#pygame.pixelcopy.surface_to... | Using the pygame function pygame.pixelcopy.surface_to_array() | python|pygame | 1 | 51 | 1 | 72,293,394 | 72,293,394 | 1 | true | 2022-05-17T10:31:56.950Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using the pygame function pygame.pixelcopy.surface_to_array()<p>I've been sitting on this for a while now but the documentation is really confusing and has n... |
72,299,880 | Htaccess rewrite condition for files with no file extension<p>I have a rewrite condition for specific file types like so:</p>
<pre><code>RewriteCond %{REQUEST_URI} .*(\/|.htaccess|.htpasswd|.ini|.log)$
</code></pre>
<p>This works fine for files with those file extensions however I can't figure out how to make it also m... | <blockquote>
<p>I can't figure out how to make it also match files with no extension.</p>
</blockquote>
<p>You may use it like this:</p>
<pre class="lang-sh prettyprint-override"><code>RewriteCond %{REQUEST_URI} ^/(?:[^.]+|.*(/|\.(?:htaccess|htpasswd|ini|log)))$
</code></pre>
<p><code>[^.]+</code> match 1 or more of an... | Htaccess rewrite condition for files with no file extension | .htaccess|mod-rewrite|url-rewriting | 2 | 51 | 1 | 72,299,902 | 72,299,902 | 1 | true | 2022-05-19T06:52:20.933Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Htaccess rewrite condition for files with no file extension<p>I have a rewrite condition for specific file types like so:</p>
<pre><code>RewriteCond %{REQUES... |
72,300,234 | Proper way to seperate piece of code as a background process<p>I have a bullCollections where I save some information about some messages example</p>
<pre><code>try {
let bullPayload = {
type: 'message',
payload: {
messsages: messagesForPreProcessingData,
sessionID: this.data... | <blockquote>
<p>Does timeout affect the performance, because the backend will handle millions of users?</p>
</blockquote>
<p>Timeouts, themselves, probably won't affect performance much. But your specific use of them will, because all it does is delay the process by <code>timeDuration</code> and then run it <strong>on ... | Proper way to seperate piece of code as a background process | javascript|node.js|redis | 0 | 51 | 1 | 72,300,592 | 72,300,592 | 1 | true | 2022-05-19T07:19:12.143Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Proper way to seperate piece of code as a background process<p>I have a bullCollections where I save some information about some messages example</p>
<pre><c... |
72,294,404 | How to Access a member of a Struct ( accessed via pointer) nested within another Struct (also accessed via pointer)?<p>I am having trouble accessing data in a nested Struct. I am trying to realize a SPI-Communication between two MCUs.
The Idea was to provide an easy to manipulate Struct to other functions which is nest... | <p>I am so Sorry. I found my mistake. I switched the order of the arguments for my initialization function and mistakenly put the pointer to the rxBuffer into the txbufferptr of the SPI-handler. The rxBuffer was empty, therefore yielding only 0.</p>
<p>I am Thankful for everyone who took the time to help me.
I am relat... | How to Access a member of a Struct ( accessed via pointer) nested within another Struct (also accessed via pointer)? | c|pointers|struct|microcontroller | 2 | 51 | 2 | 72,303,410 | 72,303,410 | 1 | true | 2022-05-18T18:38:55.973Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to Access a member of a Struct ( accessed via pointer) nested within another Struct (also accessed via pointer)?<p>I am having trouble accessing data in ... |
72,304,956 | Why can't I use removeAll on a list of objects?<p>I am trying to create an app that let's you type in what you want to eat and drink. It calculates all of that and then when you press the print button, I want it to count how often each item's in the list and give it back like this:</p>
<p>"9x Juice /n
5x Steaks /... | <p><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/remove-all.html" rel="nofollow noreferrer"><code>removeAll</code></a> is meant to take a list or a predicate, not a single element. If you convert your element to a predicate checking for equality, it will remove all elements equal to that one.... | Why can't I use removeAll on a list of objects? | android-studio|kotlin | 1 | 51 | 2 | 72,305,107 | 72,305,107 | 1 | true | 2022-05-19T12:54:54.323Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why can't I use removeAll on a list of objects?<p>I am trying to create an app that let's you type in what you want to eat and drink. It calculates all of th... |
72,309,949 | How to enable json import in OpenSCAD<p>I am trying to get the <a href="https://github.com/mmalecki/catchnhole" rel="nofollow noreferrer">catchnhole</a> library to work. Its github page mentions that json import has to be enabled, which is only available in nightly builds. I installed a nightly snapshot, but I cannot f... | <p><code>Edit</code> -> <code>Preferences</code> -> <code>Features</code> -> ✓ <code>import-function</code></p> | How to enable json import in OpenSCAD | openscad | 0 | 51 | 1 | 72,310,063 | 72,310,063 | 1 | true | 2022-05-19T19:10:47.220Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to enable json import in OpenSCAD<p>I am trying to get the <a href="https://github.com/mmalecki/catchnhole" rel="nofollow noreferrer">catchnhole</a> libr... |
72,307,726 | How to sum from multiple tables with different structure?<p>Hi I am attempting to create a "Reputation" for a user's profile by using SQL query to sum up the 'likes' & 'amount' of awards and subtracting the amount of 'dislikes'</p>
<p>I can get the sum from one table but cannot get it to work correctly wi... | <p>For the <code>articles</code> table you need to sum likes+dislikes and then use union all.</p>
<p>Try:</p>
<pre><code>select username,sum(amount) as totalRep
FROM (
select username,
(sum(likes)+sum(dislikes)) as amount
from articles
group by username
union all
select us... | How to sum from multiple tables with different structure? | mysql|sql|select | -2 | 51 | 1 | 72,314,941 | 72,314,941 | 1 | true | 2022-05-19T16:02:51.360Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to sum from multiple tables with different structure?<p>Hi I am attempting to create a "Reputation" for a user's profile by using SQL query to ... |
72,318,334 | Regex match words without alphabet<p>I want to match all words that doesn't include alphabet <code>[a-zA-Z]</code> init.</p>
<p><strong>Pass cases</strong></p>
<ul>
<li>Some Name</li>
<li>Another3 [VLT]</li>
<li>Also! (This)</li>
</ul>
<p><strong>Fail cases</strong></p>
<ul>
<li>Not 42 this</li>
<li>This is wrong (!)<... | <p>You can use</p>
<pre class="lang-none prettyprint-override"><code>(?<!\S)[^A-Za-z\s]+(?!\S)
</code></pre>
<p>See the <a href="https://regex101.com/r/rPzGW2/1" rel="nofollow noreferrer">regex demo</a>.</p>
<p><em>Details</em>:</p>
<ul>
<li><code>(?<!\S)</code> - left-hand whitespace boundary</li>
<li><code>[^A-... | Regex match words without alphabet | regex|pattern-matching|regex-negation | 1 | 51 | 1 | 72,318,766 | 72,318,766 | 1 | true | 2022-05-20T11:38:47.010Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Regex match words without alphabet<p>I want to match all words that doesn't include alphabet <code>[a-zA-Z]</code> init.</p>
<p><strong>Pass cases</strong><... |
72,320,469 | Is there a way to generate appsettings.json sections from the bound "settings" class?<p>I'm using strongly typed settings in my .NET 6 Project.</p>
<p>I'm binding the appSettings via Hostbuilder's</p>
<pre><code>.ConfigureServices((hostContext, services) =>
{
serv... | <p>As regards #2, you could use "Paste JSON as classes" (Edit -> Paste special -> Paste JSON as classes):</p>
<ol>
<li>First copy the section from <code>appsettings.json</code></li>
<li>Open a code file and insert the JSON content</li>
<li>Adjust to your needs</li>
</ol> | Is there a way to generate appsettings.json sections from the bound "settings" class? | c#|.net|dependency-injection|appsettings | -1 | 51 | 1 | 72,320,670 | 72,320,670 | 1 | true | 2022-05-20T14:19:10.017Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there a way to generate appsettings.json sections from the bound "settings" class?<p>I'm using strongly typed settings in my .NET 6 Project.</p>
<p>I'm bi... |
72,322,314 | How do you toggle the click so that the function data doesn't display the second time?<p>createData is a function which displays data and appears when the button is clicked. How do I make the data disappear every other click?</p>
<pre><code>document.getElementById("clickme").onclick = createData;
</code></pre... | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let item = document.getElementById("clickme")
let checker = true;
item.addEventListener('click', checkData);
function checkData()... | How do you toggle the click so that the function data doesn't display the second time? | javascript|html|jquery|css|json | 1 | 51 | 4 | 72,322,511 | 72,322,511 | 1 | true | 2022-05-20T16:50:39.653Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do you toggle the click so that the function data doesn't display the second time?<p>createData is a function which displays data and appears when the bu... |
72,321,528 | How to add data to list from user input<p>I have problem in adding data to my list.
Users have to enter the data, then show the data in a <code>RecycleView</code> that use a model class.</p>
<p>App works fine, but the data is not shown on the <code>RecycleView</code>.
Before everything was working good, then i added a ... | <p>Call <code>calculatorAdapter.notifyDataSetChanged()</code> after adding item to the list.</p> | How to add data to list from user input | java|android|arraylist|user-input | 0 | 51 | 1 | 72,323,293 | 72,323,293 | 1 | true | 2022-05-20T15:38:51.540Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to add data to list from user input<p>I have problem in adding data to my list.
Users have to enter the data, then show the data in a <code>RecycleView</... |
72,323,560 | How to create a comma separate aggregate in Google Sheets?<p>Given the following data set:</p>
<p><a href="https://docs.google.com/spreadsheets/d/1wr7v93CM_kWygRNHyqMWcBFvd1XXkC5SYbjLjauS4SM/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1wr7v93CM_kWygRNHyqMWcBFvd1XXkC5SYbjLjauS4SM/e... | <p>try:</p>
<pre><code>=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({A2:A&"×", B2:B&",", ROW(A2:A)},
"select max(Col2) where Col2 <> ',' group by Col3 pivot Col1"),,9^9)), "×")), ",$", ))
</code></pre>
<p><a href="https://i.stack.imgur.com/H... | How to create a comma separate aggregate in Google Sheets? | google-sheets|join|split|flatten|google-query-language | 0 | 51 | 1 | 72,323,648 | 72,323,648 | 1 | true | 2022-05-20T18:46:22.233Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to create a comma separate aggregate in Google Sheets?<p>Given the following data set:</p>
<p><a href="https://docs.google.com/spreadsheets/d/1wr7v93CM_k... |
72,321,446 | Angular - How can I move ngClass logic from template to ts file?<p>In Angular application I am using dropdown filters for user selection. I have add logic in ngClass</p>
<p><code> <div [ngClass]="i > 2 && 'array-design'"></code></p>
<p>How can I move the logic for classed to the con... | <p>You can move the conditional statement into a function and use its return in HTML.</p>
<hr />
<p>html</p>
<pre><code>[ngClass]="filterClass(i)"
</code></pre>
<p>ts</p>
<pre><code>const filterClass = (i) => i > 2 && 'array-design';
</code></pre> | Angular - How can I move ngClass logic from template to ts file? | javascript|angular|typescript|ng-class | 0 | 51 | 1 | 72,327,795 | 72,327,795 | 1 | true | 2022-05-20T15:31:25.963Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Angular - How can I move ngClass logic from template to ts file?<p>In Angular application I am using dropdown filters for user selection. I have add logic in... |
72,328,180 | Selected and unselected from HStack logic<p>i want that when i pressed on 5th box then all left box will fill , and when i click on eg. 1 then unselected last 4 box , but not 1,
if i clicked on 2nd box then last 3 will be unselected , Thank you in Advanced</p>
<pre><code> @State var SelectedAppsname = [1,2]
... | <p>Make it simple:</p>
<pre><code> @State private var level = 0
var body: some View {
HStack {
ForEach(0..<6) { index in
Button {
withAnimation {
level = index
}
} label: {
... | Selected and unselected from HStack logic | swift|swiftui | 0 | 51 | 1 | 72,328,252 | 72,328,252 | 1 | true | 2022-05-21T09:12:09.570Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Selected and unselected from HStack logic<p>i want that when i pressed on 5th box then all left box will fill , and when i click on eg. 1 then unselected las... |
72,251,656 | Powershell Register WPF events<p>I'm trying to build a WPF gui where i have two radiobutton listboxes.
A button loads the radio buttons:</p>
<pre><code>function mybuttonclick {
$List = get-content "list.txt"
foreach ($item in $list) {
$tmpradio = New-Object System.Windows.Controls.RadioButton
... | <p>Looks like i will once more answer my own question..</p>
<p>It honestly is as simple as i tought it would...
Jim Moyle explained it, i adapted to my situation..</p>
<pre><code>function mybuttonclick {
$List = get-content "list.txt"
foreach ($item in $list) {
$tmpradio = New-Object System.Wi... | Powershell Register WPF events | wpf|powershell|events | 1 | 51 | 1 | 72,329,752 | 72,329,752 | 1 | true | 2022-05-15T19:41:35.960Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Powershell Register WPF events<p>I'm trying to build a WPF gui where i have two radiobutton listboxes.
A button loads the radio buttons:</p>
<pre><code>funct... |
72,330,181 | Sort array based on string transformed into date<p>So I have an array containing reviews (which I retrieve from firebase firestore). The field 'date' is string in firestore. How can I sort the reviews in descending order based on this date? I have tried this but they are in the retrieval order.</p>
<pre><code>const get... | <p>Could you try this? It's likely that you are sorting an array of strings <code>reviewsClone</code> currently, which all have <code>.date</code> prop undefined, therefore .sort has no effect.</p>
<pre class="lang-js prettyprint-override"><code>const getReviews=async()=>{
let reviewsClone=[];
const ... | Sort array based on string transformed into date | javascript|reactjs | 1 | 51 | 2 | 72,330,217 | 72,330,217 | 1 | true | 2022-05-21T13:53:12.950Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Sort array based on string transformed into date<p>So I have an array containing reviews (which I retrieve from firebase firestore). The field 'date' is stri... |
72,330,190 | MongoDB - How to get content from a specific field only<p>What is the best way to retrieve the content from specific fields only in Mongo?</p>
<p>Using Mongoose, here is my Schema:</p>
<pre><code>module.exports = mongoose => {
const Shop = mongoose.model(
'Shop',
mongoose.Schema(
{
... | <p>try this code :</p>
<pre class="lang-js prettyprint-override"><code>const readCities = async(req, res) => {
try {
const cities = await Shop.find({}, { 'address.city' : 1});
console.log(cities);
res
.status(200)
.send('It works');
} catch (error) {
... | MongoDB - How to get content from a specific field only | node.js|mongodb|express|mongoose | 0 | 51 | 1 | 72,330,775 | 72,330,775 | 1 | true | 2022-05-21T13:54:21.370Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
MongoDB - How to get content from a specific field only<p>What is the best way to retrieve the content from specific fields only in Mongo?</p>
<p>Using Mongo... |
72,299,545 | Cluster objects by geometric coordinates (Y axis)<p>I've got a pandas DataFrame with records describing rectangles with absolute coordinates of all the 4 points: TL (top-left), TR (top-right), BL (bottom-left) and BR (bottom-right). As it is, the rects seem to follow a row-like pattern, where there are conspicuous clus... | <p>Given the dataframe you provided:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
df = pd.DataFrame(
{
"tl_x": {0: 1567, 1: 1360, 2: 1567, 3: 1311, 4: 1565, 5: 1566},
"tl_y": {0: 136, 1: 154, 2: 154, 3: 175, 4: 174, 5: 196},
"tr_x": {... | Cluster objects by geometric coordinates (Y axis) | python|pandas|geometry|classification|cluster-analysis | 1 | 51 | 1 | 72,336,386 | 72,336,386 | 1 | true | 2022-05-19T06:23:11.393Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Cluster objects by geometric coordinates (Y axis)<p>I've got a pandas DataFrame with records describing rectangles with absolute coordinates of all the 4 poi... |
72,316,417 | Plot surface where Z depends on a vector of X and Y<p>I'm currently working on a small python script which can be used to interpolate points with a radial basis function approach. Therefore I would like to plot a surface where the Z value is calculated by a vector which depends on X and Y.</p>
<p>The formula I need to... | <p>As @Mateo Vial mentioned in the comments, the simplest approach is to calculate the norm with the pythagorean formula. The working code looks like this:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt
def phi(x):
return np.exp(- np.power(x, 2))
fig = plt.... | Plot surface where Z depends on a vector of X and Y | python|numpy|matplotlib | 2 | 51 | 2 | 72,337,412 | 72,337,412 | 1 | true | 2022-05-20T09:14:27.247Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Plot surface where Z depends on a vector of X and Y<p>I'm currently working on a small python script which can be used to interpolate points with a radial b... |
72,337,715 | extract every nth element of a column in a dataset<p>Let suppose I have a dataset, named "df", with many columns, and I need to extract every fifth element of only one column, named “country”. Could anyone suggest a sample code for it?</p> | <p>Just use <code>seq</code> to create a sequence of the numbers you want, and use <code>[seq,]</code> for indexing. Aditionally, to select a given oclumn, use <code>[,"col_name"]</code></p>
<pre class="lang-r prettyprint-override"><code>df <- iris
row_seq <- seq(5, nrow(df), by=5)
df[row_seq,]
#> ... | extract every nth element of a column in a dataset | r | 0 | 51 | 3 | 72,337,768 | 72,337,768 | 1 | true | 2022-05-22T12:46:44.377Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
extract every nth element of a column in a dataset<p>Let suppose I have a dataset, named "df", with many columns, and I need to extract every fifth... |
72,343,037 | How to join multiple tables SQL together according to scenario<p>I am trying to write a query where I need to get</p>
<ul>
<li>A list containing the name (surname and first name) of any employee that has picked any product(s) for a stock request.</li>
</ul>
<p>I am confused about this as all this information is scatter... | <p>Try this:</p>
<pre><code>SELECT
concat(e.surname, ', ', e.firstName) as fullName
FROM
Picking_List pl
INNER JOIN
Employee e ON e.StaffID = pl.pickerStaffID
WHERE
pl.requestNum = :RequestNumberToLookFor
</code></pre>
<p>:RequestNumberToLookFor is the request Number of the request you are looking for.... | How to join multiple tables SQL together according to scenario | mysql|sql | 0 | 51 | 1 | 72,343,113 | 72,343,113 | 1 | true | 2022-05-23T03:40:02.797Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to join multiple tables SQL together according to scenario<p>I am trying to write a query where I need to get</p>
<ul>
<li>A list containing the name (su... |
72,342,366 | Get last child from firebase<p>I am trying to add rides to my firebase and I am using the following code:</p>
<pre><code>dbref = FirebaseDatabase.getInstance().getReference("Users")
databaseQuery = myRef.orderByKey().limitToLast(1)
firebaseAuth = FirebaseAuth.getInstance()
databaseQuer... | <p>First, make sure that you are using correct scope for your <strong><code>BuleiaId</code></strong> variable. Second, you can call either <code>get</code> or <code>addListenerForSingleValueEvent</code> for single fetch scenarios then you can add your second query by nesting into first one .</p>
<pre><code> databaseQ... | Get last child from firebase | android|firebase|kotlin|children | 0 | 51 | 2 | 72,343,627 | 72,343,627 | 1 | true | 2022-05-23T01:14:48.567Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Get last child from firebase<p>I am trying to add rides to my firebase and I am using the following code:</p>
<pre><code>dbref = FirebaseDatabase.getInstance... |
72,335,305 | Combobox SelectedItem is not working in UWP<p>I have a Combobox with some items, i fill combobox this way:</p>
<pre><code>var files = Directory.GetFiles(Constants.TranslationsPath);
var items = new ObservableCollection<Translation>();
using var db = new AlAnvarDBContext();
if (files.Count() > 0)
{
foreach ... | <pre><code>cmbTranslators.SelectedItem = cmbTranslators.Items.Where(x=>((Translation)x).Id == Settings.DefaultTranslation.Id).FirstOrDefault();
</code></pre> | Combobox SelectedItem is not working in UWP | c#|xaml|uwp|winui-3 | 0 | 51 | 2 | 72,344,191 | 72,344,191 | 1 | true | 2022-05-22T06:33:49.423Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Combobox SelectedItem is not working in UWP<p>I have a Combobox with some items, i fill combobox this way:</p>
<pre><code>var files = Directory.GetFiles(Cons... |
72,347,160 | Database contains foreign key that doesn exist even though there is a foreign key constraint?<p>I am working with a database where there is a foreign key ID that doesn't exist even though there is a foreign key constraint.</p>
<p>There is a table called "Workplace" with a foreign key column called "Addre... | <p>You create your <code>FOREIGN KEY</code> with <code>NOCHECK</code>, as a result the values that already exist in the table are <strong>not</strong> checked. This can be replicated with the following:</p>
<pre class="lang-sql prettyprint-override"><code>CREATE TABLE dbo.Address (ID int NOT NULL CONSTRAINT PK_Address ... | Database contains foreign key that doesn exist even though there is a foreign key constraint? | sql|sql-server|foreign-keys | 0 | 51 | 1 | 72,347,291 | 72,347,291 | 1 | true | 2022-05-23T10:39:10.440Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Database contains foreign key that doesn exist even though there is a foreign key constraint?<p>I am working with a database where there is a foreign key ID ... |
72,349,126 | INTERSECT between two pseudo (derived) tables in Microsoft SQL server<p>I'm trying to find out whether there are any differences between two pseudo tables with one column (see if every element in one table is in the other)</p>
<p>Code:</p>
<pre><code>SELECT *
FROM
(SELECT Orders.OrderID
FROM (((Categories FUL... | <p>The issue is that you have a FROM Clause attempting to run 2 sub selects enclosed within parenthesis.</p>
<pre><code>SELECT
*
FROM
(SELECT 1 AS a)
</code></pre>
<p>Yields an error:</p>
<p>Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ')'.</p>
<p>Adding an alias, however, works fine:</p>
<pre><cod... | INTERSECT between two pseudo (derived) tables in Microsoft SQL server | sql|sql-server | 0 | 51 | 3 | 72,349,300 | 72,349,300 | 1 | true | 2022-05-23T13:11:01.257Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
INTERSECT between two pseudo (derived) tables in Microsoft SQL server<p>I'm trying to find out whether there are any differences between two pseudo tables w... |
72,349,524 | How to modify lines that hold a given string with new information and save it as a text file<p>I am working on modifying our batch files where we call @make functions inside. We want to add a script inside the batch file that checks an external header file, finds the line with date information(APP_VERSION_DATE) and upd... | <h2>Replace date/time in header file app_version.h</h2>
<p>There could be used the following commented batch file for this task:</p>
<pre><code>@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "HeaderFile=app_version.h"
if not exist "%HeaderFile%" exit /B 20
rem Get current local dat... | How to modify lines that hold a given string with new information and save it as a text file | string|windows|if-statement|batch-file|findstr | 0 | 51 | 1 | 72,352,597 | 72,352,597 | 1 | true | 2022-05-23T13:35:51.070Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to modify lines that hold a given string with new information and save it as a text file<p>I am working on modifying our batch files where we call @make ... |
72,355,802 | How to convert object into another object<p>How i convert an object 1 into object 2 that have additional properties</p>
<pre><code>class Object1 {
var imageUrl: String
var title: String
var description: String
var order: Int
}
class Object2 {
var imageUrl: String
var title: String
var description:... | <p>You're question is tagged [oop], so I'll answer from that perspective.</p>
<p>You should avoid treating objects as dumb groups of data, that isn't what OOP is about. Aggregating related fields into records of some kind has predated OOP by decades. OOP is about polymorphism: having objects respond to the same message... | How to convert object into another object | arrays|swift|oop | 1 | 51 | 1 | 72,355,991 | 72,355,991 | 1 | true | 2022-05-23T23:36:55.170Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to convert object into another object<p>How i convert an object 1 into object 2 that have additional properties</p>
<pre><code>class Object1 {
var ima... |
72,357,486 | Pandas groupby - Find mean of first 10 items<p>I have 30 items in each group.</p>
<p>To find mean of entire items, I use this code.</p>
<pre><code>y = df[["Value", "Date"]].groupby("Date").mean()
</code></pre>
<p>That returns a value like this.</p>
<pre><code>Date Value
... | <p>You can try</p>
<pre class="lang-py prettyprint-override"><code>y1 = df[["Value", "Date"]].groupby("Date").apply(lambda g: g['Value'].head(10).mean())
</code></pre>
<pre><code>print(y1)
Date
2020-01-01 00:30:00 7172.36
2020-01-01 01:00:00 7171.55
2020-01-01 01:30:00 7205.90
20... | Pandas groupby - Find mean of first 10 items | python|pandas|pandas-groupby | 0 | 51 | 2 | 72,357,574 | 72,357,574 | 1 | true | 2022-05-24T05:13:12.073Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Pandas groupby - Find mean of first 10 items<p>I have 30 items in each group.</p>
<p>To find mean of entire items, I use this code.</p>
<pre><code>y = df[[&q... |
72,359,234 | Angular, store-select with http get<p>i would like to guard a route and do the following:</p>
<ul>
<li>check if user is in ngrx-store</li>
<li>if user is in store return true at canActivate</li>
<li>if not make an http-get and receicve user</li>
<li>if user gets back, store it in store and return true on canActivate</l... | <pre class="lang-js prettyprint-override"><code> if (!!user) {
return true; // Returns a boolean - OK
}
return this.authService.getUser$()
.pipe(
map(user => {
this.store.dispatch(addUser({user: user}));
return true; // Returns an ob... | Angular, store-select with http get | angular|httpclient|ngrx-store | 0 | 51 | 1 | 72,359,261 | 72,359,261 | 1 | true | 2022-05-24T07:59:15.173Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Angular, store-select with http get<p>i would like to guard a route and do the following:</p>
<ul>
<li>check if user is in ngrx-store</li>
<li>if user is in ... |
72,359,968 | Using time.sleep with selenium (sleep until something is completly loaded)<p>i'm trying to find a way, to sleep for as long as it takes for an selenium element to be loaded. i tried it with actionchains and with the inbuilt sleep where you can define a max sleep timeout. However after doing so, it still wasn't what i t... | <p>There is no such Expected Condition to wait until the element to be fully loaded.</p>
<p>I don't know exactly what are you trying to get but most probably the element is loaded in DOM so the expected condition is met even if the content of that element is not there yet.
If you are trying to access a button you can u... | Using time.sleep with selenium (sleep until something is completly loaded) | python|selenium|time|sleep | 0 | 51 | 1 | 72,360,319 | 72,360,319 | 1 | true | 2022-05-24T08:56:00.533Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using time.sleep with selenium (sleep until something is completly loaded)<p>i'm trying to find a way, to sleep for as long as it takes for an selenium eleme... |
72,366,258 | Same key with different flags<p>I have a table as an input which is the following:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Key</th>
<th style="text-align: left;">Flag</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">123</td>
<td style="text-al... | <p>Assuming you only want to have this output in a query rather than altering the table, You can employ the group_concat() function. This will put your distinct flags into one column with a comma delimiter. You can then put this into a case statement to get your desired output.</p>
<pre><code>select `key`,
gro... | Same key with different flags | mysql|sql | 0 | 51 | 3 | 72,366,903 | 72,366,903 | 1 | true | 2022-05-24T16:21:21.043Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Same key with different flags<p>I have a table as an input which is the following:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<... |
72,367,937 | Unable to expose docker LoadBalancer service<p>I am trying to deploy a docker image which is in public repository. I am trying to create a loadbalancer service, and trying to expose the service in my system ip address, and not 127.0.0.1.
I am using a windows 10 , and my docker has WSL2 instead of hyper-v.</p>
<p>Below ... | <p>The <code>loadBalancer</code> service type require a cloud provider's load Balancer ( <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a> )</p>
<pre><code>LoadBalancer: Exposes the Service externally... | Unable to expose docker LoadBalancer service | windows|docker|powershell|kubernetes | 0 | 51 | 1 | 72,371,565 | 72,371,565 | 1 | true | 2022-05-24T18:39:43.357Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unable to expose docker LoadBalancer service<p>I am trying to deploy a docker image which is in public repository. I am trying to create a loadbalancer servi... |
72,368,901 | Clarification on using shadow variables in optapy<p>I am trying to use shadow variables in optapy but I am not sure I understand how I can update their values correctly. The documentation of OptaPlanner suggests that to update a shadow variable, OptaPlanner uses a VariableListener, but they seem not supported in optapy... | <p>Custom shadow variables (which use custom VariableListeners) are currently not supported (tracking issue: <a href="https://github.com/optapy/optapy/issues/75" rel="nofollow noreferrer">https://github.com/optapy/optapy/issues/75</a>), but builtin shadow variables (which use predefined VariableListeners) are. The buil... | Clarification on using shadow variables in optapy | optaplanner | 0 | 51 | 1 | 72,378,817 | 72,378,817 | 1 | true | 2022-05-24T20:06:40.850Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Clarification on using shadow variables in optapy<p>I am trying to use shadow variables in optapy but I am not sure I understand how I can update their value... |
72,386,201 | Retrieve the position (X,Y) of an HTML element in Ruby<p>I have this example that displays some arbitrary text from the user:</p>
<pre><code><html>
<head></head>
<body>
<%= @article.text %>
</body>
</html>
</code></pre>
<p>I want to know how to get the X and Y pos... | <p>Set some id to element</p>
<pre><code><html>
<head></head>
<body>
<div id="my-id">
<%= @article.text %>
</div>
</body>
</html>
</code></pre>
<p>And get position in JS with <code>getBoundingClientRect</code></p>
<pre><code>const getCoordinates = ... | Retrieve the position (X,Y) of an HTML element in Ruby | html|ruby-on-rails|ruby|dom|position | 0 | 51 | 1 | 72,391,856 | 72,391,856 | 1 | true | 2022-05-26T02:58:33.873Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Retrieve the position (X,Y) of an HTML element in Ruby<p>I have this example that displays some arbitrary text from the user:</p>
<pre><code><html>
&l... |
72,795,256 | Unable to send objects as payload data while making an Fetch API request<p>I have a react frontend and node backend, I am fetching a list of objects from an external API using Axios and then trying to pass it to my node backend. The issue is that the node backend is not able to receive this payload data on the backend,... | <p>You can <code>stringify</code> the array of objects before sending. Use <code>JSON.stringify</code></p>
<pre><code>const x = [{ x: 1 }, { x: 2 }];
fetch("https://httpbin.org/post", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": &... | Unable to send objects as payload data while making an Fetch API request | javascript|node.js|reactjs|fetch-api|mern | -1 | 51 | 1 | 72,795,361 | 72,795,361 | 1 | true | 2022-06-29T02:51:27.250Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unable to send objects as payload data while making an Fetch API request<p>I have a react frontend and node backend, I am fetching a list of objects from an ... |
72,769,016 | Generate a chunk name without hash<p>For my specific condition I don't want to generate hash in file name for some specific files. I tried something like this, but its removing hash from .css files but not for the .js files.</p>
<pre><code> build: {
target: 'es2020',
rollupOptions: {
input: {
mai... | <p>Use method entryFileNames as its the entry file.
<a href="https://rollupjs.org/guide/en/#outputentryfilenames" rel="nofollow noreferrer">https://rollupjs.org/guide/en/#outputentryfilenames</a></p> | Generate a chunk name without hash | javascript|vite|rollupjs | -1 | 51 | 1 | 72,795,539 | 72,795,539 | 1 | true | 2022-06-27T08:20:53.723Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Generate a chunk name without hash<p>For my specific condition I don't want to generate hash in file name for some specific files. I tried something like thi... |
72,791,043 | How would I fix the issue of the python extension loading and Extension activation failed messages appearing?<p><a href="https://i.stack.imgur.com/rxPrx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rxPrx.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/bLvRV.png" r... | <p>Please update the <a href="https://marketplace.visualstudio.com/items?itemName=ms-python.python" rel="nofollow noreferrer">python extension</a> to the <em>latest</em> version</p>
<p><a href="https://i.stack.imgur.com/3cXXS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3cXXS.png" alt="enter image... | How would I fix the issue of the python extension loading and Extension activation failed messages appearing? | python|visual-studio-code|loading | 0 | 51 | 1 | 72,796,261 | 72,796,261 | 1 | true | 2022-06-28T17:48:59.613Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How would I fix the issue of the python extension loading and Extension activation failed messages appearing?<p><a href="https://i.stack.imgur.com/rxPrx.png"... |
72,803,915 | How do i make python look for a specific word<p>So i have this code:</p>
<pre><code>x = 1
while x <= 2:
text = input("> ")
to_deny = "!?/"
find=["find subsystem"]
if any(char in text for char in to_deny):
print("text contains restricted characters")
... | <p>Put all the mutually exclusive operations that don't result in a <code>break</code> or <code>continue</code> in a single <code>if...elif...else</code> chain so that you don't "fall through" from one into the next.</p>
<pre><code>import os
to_deny = "!?/"
find = "find subsystem "
while ... | How do i make python look for a specific word | python | -3 | 51 | 2 | 72,804,111 | 72,804,111 | 1 | true | 2022-06-29T15:18:25.547Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do i make python look for a specific word<p>So i have this code:</p>
<pre><code>x = 1
while x <= 2:
text = input("> ")
to_deny = ... |
72,804,589 | Script that execute C by Bash<p>What should a script that compiles and executes a C program look like?
By condition, the script must be run with the following flags:
gcc -Wall -Werror -Wextra -o</p>
<p>In my understanding, when running the script, I have to enter the name of the program file</p>
<pre><code>% gcc -Wall ... | <p>The script can take the name of the program as an argument, which you access using <code>$1</code>. Then substitute that for the file name in the commands.</p>
<pre><code>#!/bin/sh
prog="$1"
if gcc -Wall -Werror -Wextra "$prog".c -o "$prog"
then "./$prog"
else
echo "... | Script that execute C by Bash | c|bash | 0 | 51 | 2 | 72,804,691 | 72,804,691 | 1 | true | 2022-06-29T16:06:02.387Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Script that execute C by Bash<p>What should a script that compiles and executes a C program look like?
By condition, the script must be run with the followin... |
72,804,701 | illegal offset type in php on vscode no error, but on page says that error<p>hello i'm running into a problem, it says on the browser illegal offset type,
im declaring an array this way:</p>
<pre><code> $matriculas = [
1 => ["99-99-99", "D"],
2 => ["88-88-88", "D... | <p>It's almost right.</p>
<p>Based on the subsequent <code>foreach ($series as $ID => $values)</code>, I think you want this instead:</p>
<pre><code>foreach ($options as $option) {
$series[$option['id']] = [$option['matricula'], $option['type']];
}
</code></pre>
<p>But unless you're going to use the <code>$optio... | illegal offset type in php on vscode no error, but on page says that error | php | -3 | 51 | 3 | 72,804,826 | 72,804,826 | 1 | true | 2022-06-29T16:13:58.997Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
illegal offset type in php on vscode no error, but on page says that error<p>hello i'm running into a problem, it says on the browser illegal offset type,
im... |
72,803,431 | Unit testing OverflowException : Maximum retries of 10000 reached without finding a unique value<p>So I am working on some unit testing before I implement a new feature. I run my test and it fails with <code>OverflowException : Maximum retries of 10000 reached without finding a unique value</code> This is the test I'm ... | <p>I will recommend to follow documentation approach for this problem.
<a href="https://laravel.com/docs/9.x/database-testing#factory-relationships" rel="nofollow noreferrer">https://laravel.com/docs/9.x/database-testing#factory-relationships</a></p>
<p>Looking at your migration table, there is a big chance that your f... | Unit testing OverflowException : Maximum retries of 10000 reached without finding a unique value | php|laravel|phpunit|factory | 0 | 51 | 1 | 72,806,568 | 72,806,568 | 1 | true | 2022-06-29T14:48:36.843Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unit testing OverflowException : Maximum retries of 10000 reached without finding a unique value<p>So I am working on some unit testing before I implement a ... |
72,807,722 | convert string property from api to JSON object<p>i'm making a call to an api which returns data to the front end in this format</p>
<pre><code>{ name: 'Fred',
data: [{'name': '"10\\" x 45\\" Nice Shirts (2-pack)"', 'price': '$30.25'}]
}
</code></pre>
<p>the data property is return as a string and ... | <p>Your backend is not returning a valid json. It should be:</p>
<pre><code>{"name": "Fred", "data": [{"name": "\\"10\\\\\\" x 45\\\\\\" Nice Shirts (2-pack)\\"", "price": "$30.25"}]}
</code></pre> | convert string property from api to JSON object | javascript|angular|typescript | -2 | 51 | 1 | 72,807,873 | 72,807,873 | 1 | true | 2022-06-29T20:51:43.737Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
convert string property from api to JSON object<p>i'm making a call to an api which returns data to the front end in this format</p>
<pre><code>{ name: 'Fred... |
72,806,369 | Viewing coefficients for each level in an ordinal CLMM model<h1>Overview</h1>
<p>I want to access the intercepts and coefficients for each level in a multilevel ordinal response model using the <code>ordinal::clmm</code> function in <code>R</code>.</p>
<p>I can easily do this with multilevel linear models estimated usi... | <p>For model <code>test1</code> fitted by <strong>lme4</strong>, calling <code>coef(test1)</code> is internally doing <code>lme4:::coef.merMod(test1)</code>. This is a user-friendly routine that adds fixed-effect coefficients and random-effect coefficients (conditional mode) together. Below is the source code of this n... | Viewing coefficients for each level in an ordinal CLMM model | r|regression|lme4|mixed-models|ordinal | 1 | 51 | 1 | 72,807,959 | 72,807,959 | 1 | true | 2022-06-29T18:45:12.833Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Viewing coefficients for each level in an ordinal CLMM model<h1>Overview</h1>
<p>I want to access the intercepts and coefficients for each level in a multile... |
72,808,893 | mantain a sum in list comprehension?<p>this is my code</p>
<pre><code>def width2colspec(widths):
tupleback = []
a=0
for w in widths:
b=a+w
tupleback.append((a,a+w))
a=b
return tupleback
</code></pre>
<p>eg:</p>
<pre><code>widths=[15,9,50,10]
width2colspec(widths)
</code></pre>
<p... | <p>You <em>can</em> do this as a pure list comprehension, but it involves a lot of re-computation, so I wouldn't recommend actually doing it this way.</p>
<p>Start by building a list of all the sums (note that this is re-summing the same numbers over and over, so it's less efficient than your original code that keeps a... | mantain a sum in list comprehension? | python|list-comprehension | 0 | 51 | 2 | 72,808,931 | 72,808,931 | 1 | true | 2022-06-29T23:37:43.730Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
mantain a sum in list comprehension?<p>this is my code</p>
<pre><code>def width2colspec(widths):
tupleback = []
a=0
for w in widths:
b=a+... |
72,817,833 | import cv2 import os cap = cv2.VideoCapture(0) recognizer = cv2.face.LBPHFaceRecognizer_create() cascadePath = "haarcascade_frontal<p>I tried to run the program, but it displays the error result as above, Has anyone experienced this error before? here is my code :</p>
<pre><code>import cv2
import os
cap = cv2.VideoCap... | <p>I hope this one can help you
looks like you forgot to add this command :</p>
<pre><code>import cv2
import os
cap = cv2.VideoCapture(0)
recognizer = cv2.face.LBPHFaceRecognizer_create()
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath);
font = cv2.FONT_HE... | import cv2 import os cap = cv2.VideoCapture(0) recognizer = cv2.face.LBPHFaceRecognizer_create() cascadePath = "haarcascade_frontal | python|opencv|keras|operating-system|artificial-intelligence | -1 | 51 | 1 | 72,818,186 | 72,818,186 | 1 | true | 2022-06-30T14:48:26.990Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
import cv2 import os cap = cv2.VideoCapture(0) recognizer = cv2.face.LBPHFaceRecognizer_create() cascadePath = "haarcascade_frontal<p>I tried to run the prog... |
72,822,153 | Does anyone know what this stack is called SwfitUI?<p>I'll keep it quick: Does anyone know if SwiftUI have a built in method that renders something like this image: <a href="https://i.stack.imgur.com/vOBjm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vOBjm.png" alt="enter image description here" /... | <p>This is a picker. to be precise, this is a segmented picker.</p>
<p>You can create it like so:</p>
<pre><code>struct ContentView: View {
@State private var favoriteColor = 0
var body: some View {
Picker("What is your favorite color?", selection: $favoriteColor) {
Text(&... | Does anyone know what this stack is called SwfitUI? | swift|xcode|swiftui|swiftui-navigationview | -3 | 51 | 1 | 72,822,261 | 72,822,261 | 1 | true | 2022-06-30T21:19:59.360Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Does anyone know what this stack is called SwfitUI?<p>I'll keep it quick: Does anyone know if SwiftUI have a built in method that renders something like this... |
72,823,610 | Iterate through a String while placing its values in a Dataframe<p>I am trying to place all of a strings values, into a data frame where the rows*columns= the length of the string. So for i have</p>
<pre><code>for i in range (len(string)):
while(j<len(df)|z<len(df.columns)):
df[j][z]=string[i]
df
</cod... | <p>You can turn the string into an array of the appropriate size with something like</p>
<pre><code>np.array(list(string)).reshape(len(df), -1)
</code></pre>
<p>Placing it in the DF should be simple after that, assuming it has a character dtype across all columns.</p> | Iterate through a String while placing its values in a Dataframe | python|pandas|string|dataframe | 1 | 51 | 1 | 72,823,640 | 72,823,640 | 1 | true | 2022-07-01T01:44:39.593Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Iterate through a String while placing its values in a Dataframe<p>I am trying to place all of a strings values, into a data frame where the rows*columns= th... |
72,822,766 | With a CheckPointed function in Flink, does the user call initializeState and snapshotState or is it handled behind the scenes<p>I am following an example here: <a href="https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/StatefulSequenceSource.... | <p>The methods will be called by the Flink framework when it needs to (when performing a checkpoint or a save point).</p>
<p>See <a href="https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/datastream/fault-tolerance/state/#using-operator-state" rel="nofollow noreferrer">https://nightlies.apache.org/flink/fli... | With a CheckPointed function in Flink, does the user call initializeState and snapshotState or is it handled behind the scenes | apache-flink|flink-streaming|flink-state | 0 | 51 | 1 | 72,825,362 | 72,825,362 | 1 | true | 2022-06-30T22:48:37.850Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
With a CheckPointed function in Flink, does the user call initializeState and snapshotState or is it handled behind the scenes<p>I am following an example he... |
72,824,506 | PHP uploading CSV file and using first line as the KEYS instead of 0,1,2<p>I am working on a CSV file upload function. The whole script is working fine and the way I am doing it is by eliminating the first line of the CSV file which is the heading and then using the data only to insert into the database. However, this ... | <p>Since you already got the keys inside <code>$getFileKeys</code> variable you can simply use a for loop to loop through the array of keys and dynamically assign the indexes based upon the field.</p>
<pre><code>$getFileKeys = fgetcsv($csvFile);
$keys = [];
for($i = 0; $i < count($getFileKeys); $i++){
if($getFile... | PHP uploading CSV file and using first line as the KEYS instead of 0,1,2 | php|csv|file | -1 | 51 | 2 | 72,829,029 | 72,829,029 | 1 | true | 2022-07-01T04:52:42.283Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
PHP uploading CSV file and using first line as the KEYS instead of 0,1,2<p>I am working on a CSV file upload function. The whole script is working fine and t... |
72,832,509 | Tensorflow equivalent for cv2.addWeighted?<p>Is there a TensorFlow equivalent for <code>cv2.addWeighted()</code>? I need this function for image processing on my <code>tf.dataset</code> object.</p>
<p>If there isn't, how can I use the OpenCV method with TensorFlow to get the same result?</p>
<p>Here is my code below fo... | <p>I think I may have found a work-around by using other tensorflow functions.</p>
<pre><code>import tensorflow as tf
import tensorflow_addons as tfa
def tensorflow_addWeighted(img1, img2):
img = img1 * tf.multiply(tf.ones(image1_shape, dtype = tf.uint8), alpha) + img2 * tf.multiply(tf.ones(image2_shape, dtype = t... | Tensorflow equivalent for cv2.addWeighted? | python|tensorflow|opencv|image-processing|computer-vision | 4 | 51 | 1 | 72,833,226 | 72,833,226 | 1 | true | 2022-07-01T16:58:22.533Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Tensorflow equivalent for cv2.addWeighted?<p>Is there a TensorFlow equivalent for <code>cv2.addWeighted()</code>? I need this function for image processing o... |
72,825,880 | Dynamic height of UIImageView in UIScrollView - iOS<p>I am trying to make my UIImageView height dynamic but it is not working. The structure is</p>
<pre><code>[UIView]
[UIScrollView]
[UIImageView]
[UILabel]
[UILabel]
[UITextField]
[UIButton]
[UIButton]
</code></pre>
<p>Everything except ImageV... | <p>First, a couple tips when posting a question like this...</p>
<ul>
<li>Rename your UI elements so it makes sense when looking at the document outline</li>
<li>When working on your layout during development, give the UI elements contrasting background colors to make it easy to see the frames</li>
<li>When posting a s... | Dynamic height of UIImageView in UIScrollView - iOS | ios|xcode|autolayout|storyboard|constraints | -1 | 51 | 1 | 72,834,418 | 72,834,418 | 1 | true | 2022-07-01T07:37:28.333Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Dynamic height of UIImageView in UIScrollView - iOS<p>I am trying to make my UIImageView height dynamic but it is not working. The structure is</p>
<pre><cod... |
72,835,830 | Stubbing link inside an iframe<p>I have an iframe containing an element with an href, when I click I want to stub the call and verify the url.</p>
<p>This is my code so far, not working. The error is "Timed out retrying after 8000ms: expected open to have been called at least once"</p>
<pre><code>cy.window().... | <p>The <code><iframe></code> has a different window to the one returned by <code>cy.window()</code>.</p>
<p>You can obtain the iframe contentWindow first and place the stub on that.</p>
<pre class="lang-js prettyprint-override"><code>cy.get('iframe')
.its('0.contentWindow')
.then(iframeWin => {
cy.stu... | Stubbing link inside an iframe | iframe|cypress | 2 | 51 | 1 | 72,835,905 | 72,835,905 | 1 | true | 2022-07-02T01:17:37.790Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Stubbing link inside an iframe<p>I have an iframe containing an element with an href, when I click I want to stub the call and verify the url.</p>
<p>This is... |
72,836,130 | how to add values to a nested dictionary json?<p>I'm trying to figure out how to add to a dictionary but not just any dictionary it a nested dictionary and relates to a recent question I asked here. <a href="https://stackoverflow.com/questions/72623864/how-can-to-get-the-json-out-of-webpage">How can to get the JSON out... | <p>You can iterate your list of dictionaries, searching for a match with <code>operator_name</code> on the <code>name</code> key, and if found, appending a dictionary of <code>log_description</code> and <code>log_id</code> to the <code>logs</code> list. If not found, you would append a new dictionary (with <code>name</... | how to add values to a nested dictionary json? | python|loops|dictionary | 0 | 51 | 1 | 72,836,160 | 72,836,160 | 1 | true | 2022-07-02T02:49:04.123Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to add values to a nested dictionary json?<p>I'm trying to figure out how to add to a dictionary but not just any dictionary it a nested dictionary and r... |
72,810,602 | How do I filter for ECR images created in the past week<p>I am using the boto3 api, but open to using CLI if it gives any more flexibility.</p>
<pre><code>client = boto3.session.Session(profile_name="prod").client("ecr", region_name="us-east-1")
response = client.describe_images(repository... | <p>When you look at the BOTO3 documentation for (ecr.describe_images)[https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecr.html#ECR.Client.describe_images], you will see a few things:</p>
<ul>
<li>An optional <code>nextToken</code> parameter</li>
<li>An optional <code>maxResults</code> paramet... | How do I filter for ECR images created in the past week | amazon-web-services|boto3 | 0 | 51 | 1 | 72,840,935 | 72,840,935 | 1 | true | 2022-06-30T05:17:36.527Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I filter for ECR images created in the past week<p>I am using the boto3 api, but open to using CLI if it gives any more flexibility.</p>
<pre><code>cl... |
72,842,235 | What is the difference between the operator acting elementwise vs on the matrix using Numpy?<p><a href="https://numpy.org/devdocs/user/quickstart.html#basic-operations" rel="nofollow noreferrer">Numpy docs</a> talks about the difference between the product operator and the matrix operator.</p>
<blockquote>
<p>Unlike in... | <p>Say we've got two matrices:</p>
<pre><code>a = [ p q ]
[ r s ]
b = [ w x ]
[ y z ]
</code></pre>
<p>Element-wise product means:</p>
<pre><code>a * b = [ p*w q*x ]
[ r*y s*z ]
</code></pre>
<p>Matrix product means:</p>
<pre><code>a @ b = [ (p*w)+(q*y) (p*x)+(q*z) ]
[ (r*w)+(s*y) (r*x)+(s*... | What is the difference between the operator acting elementwise vs on the matrix using Numpy? | python|python-3.x|numpy|operators | -1 | 51 | 1 | 72,842,276 | 72,842,276 | 1 | true | 2022-07-02T20:30:04.490Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
What is the difference between the operator acting elementwise vs on the matrix using Numpy?<p><a href="https://numpy.org/devdocs/user/quickstart.html#basic-... |
72,842,324 | Multivariate time series - is there notation to select all the variables, or do they all have to be written out?<p>I'm working to build a multivariate time series to make predictions about labor in the United States. The fpp3 package is excellent, but I don't see a notation to model all the variables.</p>
<p>For exampl... | <p>You should be able to do something like</p>
<pre class="lang-r prettyprint-override"><code>resp <- "Total_Employees"
form <- reformulate(response = resp,
c(setdiff(names(Monthly_labor_data_small), resp),
"season()", "trend()"))
</code></pre>
<p>And then use <code>form</code... | Multivariate time series - is there notation to select all the variables, or do they all have to be written out? | r|model|time-series|tidyverse|forecasting | 1 | 51 | 1 | 72,842,571 | 72,842,571 | 1 | true | 2022-07-02T20:46:10.507Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Multivariate time series - is there notation to select all the variables, or do they all have to be written out?<p>I'm working to build a multivariate time s... |
72,843,254 | VSCode compile C++ with external classes - undefined reference to `MyClass::MyClass()'<p>Error when compiling my <code>main</code> file & external <code>Class file</code> using VScode.</p>
<p>file structure:</p>
<pre><code>project/
--main.cpp
--MyClass.cpp
--MyClass.h
</code></pre>
<p>MyClass.h</p>
<pre><code>#i... | <p>Change main.cpp's includes to:</p>
<pre><code>#include <iostream>
#include <string>
#include "MyClass.cpp"
</code></pre>
<p>By including MyClass.cpp in main.cpp and compiling like this:</p>
<pre><code>g++ -o main main.cpp
</code></pre>
<p>you end up including MyClass.h by virtue of it being inc... | VSCode compile C++ with external classes - undefined reference to `MyClass::MyClass()' | c++|visual-studio-code | 0 | 51 | 1 | 72,843,314 | 72,843,314 | 1 | true | 2022-07-03T00:27:55.003Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
VSCode compile C++ with external classes - undefined reference to `MyClass::MyClass()'<p>Error when compiling my <code>main</code> file & external <code>... |
72,841,511 | Vectorizing torch tensor instead of using for loop<p>I am looking to make this calculation without using any for loops (vectorized) but cant really seem to find a good solution. Maybe someone can help?</p>
<pre><code> edge_in = torch.ones(len(edge_embeds), len(edge_embeds[0]), len(edge_embeds[0][0]) + 2*len(nodes_a_... | <p>You can expand <code>nodes_a_embed</code> and <code>nodes_b_embeds</code> to the same shape as <code>edge_embeds</code> and concatenate them directly:</p>
<ul>
<li><code>nodes_a_embed = nodes_a_embeds[:, None].expand(-1, n_B, -1)</code>: [n_A, node_dim] => [n_A, n_B, node_dim]</li>
<li><code>nodes_b_embed = nodes... | Vectorizing torch tensor instead of using for loop | python|for-loop|pytorch|vectorization|tensor | 1 | 51 | 1 | 72,844,163 | 72,844,163 | 1 | true | 2022-07-02T18:28:56.480Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Vectorizing torch tensor instead of using for loop<p>I am looking to make this calculation without using any for loops (vectorized) but cant really seem to f... |
72,839,870 | How can I protect some endpoints from user accessing it directly in django?<p>There is a URL with an endpoint named as <code> 'otp/'</code>, I don't want the user to access this endpoint directly, I want to have them as directed by my code (whenever needed)</p>
<p>How can I do it?</p>
<p>here is my code</p>
<pre><code>... | <p>There is easy way to do it just in get method check referrer:</p>
<pre><code> def get(self, request, *args, **kwargs):
if request.META['HTTP_REFERER'] != '/mylogin/':
return HttpResponseForbidden()
otp_form = OTP_Form()
return render(request, 'otp.html', {'otp_form': otp_form})
</code></pre>
... | How can I protect some endpoints from user accessing it directly in django? | python|django | 0 | 51 | 3 | 72,845,187 | 72,845,187 | 1 | true | 2022-07-02T14:33:18.283Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I protect some endpoints from user accessing it directly in django?<p>There is a URL with an endpoint named as <code> 'otp/'</code>, I don't want the... |
72,844,941 | React. How to display only 3 elements from an array instead of 5 and how to make it so that when the timer expires, these elements randomly changed?<p>How to display only 3 elements from the array instead of 5 and how to make these elements randomly change after the timer expires? I understand that I need to create a f... | <p>You can first create a state <code>selectedItems</code> which will contain random 3 elements.</p>
<pre><code>const [selectedItems, setSelectedItems] = useState(() =>
getRandomElements(appState.objects, 3)
);
</code></pre>
<p><a href="https://codesandbox.io/s/intelligent-glitter-3keig2?file=/src/CurrentEventsI... | React. How to display only 3 elements from an array instead of 5 and how to make it so that when the timer expires, these elements randomly changed? | reactjs|timer | 0 | 51 | 1 | 72,845,348 | 72,845,348 | 1 | true | 2022-07-03T08:21:03.810Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
React. How to display only 3 elements from an array instead of 5 and how to make it so that when the timer expires, these elements randomly changed?<p>How to... |
72,845,699 | Add reference to a single DLL file<p>I would like to add a reference to <code>/path/to/lib.dll</code> using the .NET CLI. All the results on google tell me how to add a <em>project</em> reference, but I want to add a single DLL file that is not in a project. I know how to do this in Visual studio, but how do I do it fr... | <p>edit your <code>.csproj</code> and add:</p>
<pre><code><ItemGroup>
<Reference Include="MyAssembly">
<HintPath>path\to\MyAssembly.dll</HintPath>
</Reference>
</ItemGroup>
</code></pre>
<p>and then <code>dotnet restore</code></p>
<p>Reference: <a href="https://medi... | Add reference to a single DLL file | c#|dotnet-cli | 1 | 51 | 1 | 72,845,748 | 72,845,748 | 1 | true | 2022-07-03T10:23:35.683Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Add reference to a single DLL file<p>I would like to add a reference to <code>/path/to/lib.dll</code> using the .NET CLI. All the results on google tell me h... |
72,850,858 | BlocBuilder vs BlocListener<p>I have a very specific question when reading the documentation.</p>
<p>After reading the <a href="https://pub.dev/documentation/flutter_bloc/latest/flutter_bloc/BlocBuilder-class.html" rel="nofollow noreferrer">BlocBuilder</a> documentation, I then went on by reading about the <a href="htt... | <p>The builder is run as you say upon state change. But the builder function is also run when the framework deems necessary to rebuild.</p>
<p>The listener function is not affected by the frameworks need to rebuild.</p> | BlocBuilder vs BlocListener | flutter|bloc|state-management|cubit | 0 | 51 | 2 | 72,853,285 | 72,853,285 | 1 | true | 2022-07-04T00:54:50.553Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
BlocBuilder vs BlocListener<p>I have a very specific question when reading the documentation.</p>
<p>After reading the <a href="https://pub.dev/documentation... |
72,860,708 | Kubectl Patch Error: does not contain declared merge key: name<p>Trying to update the resources of my Deployment using <code>kubectl patch</code> command:</p>
<pre><code>kubectl patch statefulset test -n test --patch '{"spec": {"template": {"spec": {"containers": [{"resource... | <p>It needs to know which container you want to patch in the statefulset. You indicate this by including the name of the container.</p>
<p>Also, the json structure of your resources field is incorrect. See the example below for a complete working example:</p>
<p>(replace <strong>???</strong> with the name of the contai... | Kubectl Patch Error: does not contain declared merge key: name | kubernetes|kubectl | 0 | 51 | 1 | 72,864,185 | 72,864,185 | 1 | true | 2022-07-04T18:21:03.103Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Kubectl Patch Error: does not contain declared merge key: name<p>Trying to update the resources of my Deployment using <code>kubectl patch</code> command:</p... |
72,862,726 | Clustering 1D vector with window<p>I am trying to identify clusters of 1s in a 1D vector. The problem I have is that the clusters that are separated by a number of zeros, that are less than a certain threshold, should be grouped together. Say, if I have two clusters separated by less than 3 zeros, they should be consid... | <p>Another solution, not requiring the use of <code>.apply()</code>:</p>
<pre><code>import pandas as pd
# Store the initial list in a pandas Series
ser = pd.Series([0,0,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,0,0,0,1,1,1])
</code></pre>
<p>First, identify and number each consecutive group of 1's and 0's with the size of that gr... | Clustering 1D vector with window | python|pandas|cluster-analysis|rolling-computation | 1 | 51 | 2 | 72,864,577 | 72,864,577 | 1 | true | 2022-07-04T23:20:36.583Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Clustering 1D vector with window<p>I am trying to identify clusters of 1s in a 1D vector. The problem I have is that the clusters that are separated by a num... |
72,848,756 | Parametrize a Pytest using a dictionary with key/value individual pairs mapping<p>Have multiple tests in one test class. I would like to use a dictionary to parametrize the class.</p>
<p>Dictionary structure: <code>{key1: [val_1, val2], key2: [val_3, val4]}</code></p>
<p>Test:</p>
<pre><code>@pytest.mark.parametrize('k... | <p>Here is a solution using a call to an external function in charge of formatting names from parameters value.</p>
<pre class="lang-py prettyprint-override"><code>def idfn(val):
# receive here each val
# so you can return a custom property
return val.name
@pytest.mark.parametrize(
"key, value&qu... | Parametrize a Pytest using a dictionary with key/value individual pairs mapping | pytest | 0 | 51 | 1 | 72,864,655 | 72,864,655 | 1 | true | 2022-07-03T17:57:11.750Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Parametrize a Pytest using a dictionary with key/value individual pairs mapping<p>Have multiple tests in one test class. I would like to use a dictionary to ... |
72,857,317 | Reason of equals keyword in LINQ's join statement<p>Here is a LINQ query:</p>
<pre><code>from a in db.Table1
join b in db.Table2 on a.Id1 equals b.Id2
</code></pre>
<p>I am wondering the reason of <code>equals</code> keyword.</p>
<p>Why did the LINQ creators have to create this keyword? Couldn't they work with <code>==... | <p>As per <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/join-clause#the-equals-operator" rel="nofollow noreferrer">Microsoft's docs</a>:</p>
<blockquote>
<p>A <code>join</code> clause performs an equijoin. In other words, you can only base matches on the equality of two keys. Other... | Reason of equals keyword in LINQ's join statement | linq | 0 | 51 | 1 | 72,865,339 | 72,865,339 | 1 | true | 2022-07-04T13:10:41.827Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Reason of equals keyword in LINQ's join statement<p>Here is a LINQ query:</p>
<pre><code>from a in db.Table1
join b in db.Table2 on a.Id1 equals b.Id2
</code... |
72,866,252 | Redux Query Dependent Mutations With Rollback Using createApi()<p>I have two mutations that need to happen one after another if the first one succeeds. As bonus I would like to undo the first mutation if the second fails.</p>
<p>I have the first part working but it feels clumsy and I'm wondering if there is better way.... | <p>You can just handle both in <code>handleListIt</code>, there is really no good reason for the re-render with the useEffect. And then you can also handle the rollback as you want.</p>
<pre class="lang-js prettyprint-override"><code>const handleListIt = async () => {
if (deviceListing && subscriptions) ... | Redux Query Dependent Mutations With Rollback Using createApi() | reactjs|react-redux|rtk-query | 0 | 51 | 1 | 72,867,828 | 72,867,828 | 1 | true | 2022-07-05T08:27:43.860Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Redux Query Dependent Mutations With Rollback Using createApi()<p>I have two mutations that need to happen one after another if the first one succeeds. As bo... |
72,868,816 | Python - argsort sorting incorrectly<p>What is the problem? Where am I doing wrong?</p>
<p>I am new to Python and I could not find the problem. Thanks a lot in advance for your help.</p>
<p><strong>The code is</strong></p>
<pre><code>import numpy as np
users = [["Richard", 18],["Sophia", 16],["... | <p>The numbers are being interpreted as strings (so '15' comes before '2', like 'ae' comes before 'b'). The fact that in the output, you see things like '15' with single quotes around it, is a clue to this.</p>
<p>In order to create a numpy array which has a mixture of data types (strings for the names, ints for the n... | Python - argsort sorting incorrectly | python|arrays|numpy|sorting|np.argsort | 1 | 51 | 4 | 72,868,880 | 72,868,880 | 1 | true | 2022-07-05T11:38:37.570Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python - argsort sorting incorrectly<p>What is the problem? Where am I doing wrong?</p>
<p>I am new to Python and I could not find the problem. Thanks a lot ... |
72,870,599 | How to perform ifelse on multiple columns?<p>I have sample dataframe</p>
<pre><code>dat <- data.frame(
variable1 = c(NA,2,3,4,5,6,99),
variable2 = c(NA,2,99,4,5,6,7),
variable3 = c(NA,2,3,4,5,6,7),
variable4 = c(5:11),
variable5 = c(1,2,3,4,5,6,999),
variable6 = c(1,2,3,4,999,6,7),
variable7 = c(1:7)
)... | <p><code>dplyr::case_when</code> is perfect for this:</p>
<pre><code>library(dplyr)
dat %>%
mutate(across(all_of(1:7), ~as.numeric(.))) %>% #important for all data to be numeric
mutate(variable8 = case_when(is.na(variable1) & is.na(variable2) & is.na(variable3) ~ variable4,
... | How to perform ifelse on multiple columns? | r|dplyr | 0 | 51 | 2 | 72,871,726 | 72,871,726 | 1 | true | 2022-07-05T13:51:05.857Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to perform ifelse on multiple columns?<p>I have sample dataframe</p>
<pre><code>dat <- data.frame(
variable1 = c(NA,2,3,4,5,6,99),
variable2 = c(N... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.