Skip to content
Fix Code Error

Tag: arrays

Test that the last nth rows of an array are all zeros

July 17, 2021 by Code Error

Posted By: Anonymous I have this array: A = np.array([[[ 1.8, -3.1, -3.5, 2.2], [ 1.5, -6.6, 1.1, 1.1], [ 8.9, 4.8, -1.2, 3.6], [ 1.3, -7.4, 7.4, 1. ], [ 6.3, 0. , 0. , 3. ], [ 6.3, 0. , -6.3, 0. ], [ 6.3, -6.3, 6.3, 3.3], [ 0. , 0. , …

Continue Reading

Trying to create array of strings to use in a destructuring function for removing object properties, only single string value works

July 17, 2021 by Code Error

Posted By: Anonymous I have an array of objects as part of a data response that I am grouping together using lodash’s groupBy via each object’s groupName key. Some of the items that come back have a groupName value of null, undefined or an empty string and lodash creates separate groups for each of those …

Continue Reading

ReactJS create array from json object for select option

July 17, 2021 by Code Error

Posted By: Anonymous Hi I am very new to reactjs. I have a hosted json file as below. Json object looks like below with Around 500+ values: [ { "timestamp": "2020-03-23T14:00:00.000Z", "symbol": "CMG", "name": "Chipotle Mexican Grill", "industry": "Consumer Discretionary", "open": 561.31, "high": 602.265, "low": 551.21, "close": 588.71, "volumes": 1281710 }, { "timestamp": "2020-03-23T14:00:00.000Z", "symbol": …

Continue Reading

The view function did not return a valid response. The function either returned None or ended without a return statement

July 17, 2021 by Code Error

Posted By: Anonymous I try return the result of function np.correlate, using flask and numpy from flask import Flask import numpy as np app = Flask(__name__) @app.route("/") def corelation(): # 1 2 3 8 9 7 3 12 65 45 26 33 firstArray = np.loadtxt("C:\Users\user\source\repos\CorelationApplication\firstfile.txt") # 43 32 23 45 65 99 77 11 20 …

Continue Reading

how to get an array from a data frame

July 17, 2021 by Code Error

Posted By: Anonymous How can I get an array form a column in data frame satisfying a condition? example: x=data.frame(pn=c(‘a’,’b’,’c’,’d’,’e’,’f’),price=c(1,2,3,4,5,6)) Then, for a given list of pn (an array that can have any size), like this: y=c(‘a’,’b’,’f’,’a’,’a’,’b’,’b’,’a’,’f’,’f’) I want an array of prices regarding y. The expected output is: 1,2,6,1,1,2,2,1,6,6 (No loop or lambda function) …

Continue Reading

Only getting two of three result in loop to display array elements

July 16, 2021 by Code Error

Posted By: Anonymous I can’t seem to figure out why I keep getting 1st and 3rd row. I am skipping 2nd for some reason. Here’s my code _x000D_ _x000D_ //define books and authors var books = [ { title: “Data Structures and Algorithm Analysis in C++”, publisher: “Pearson”, authors: [ {firstName: “Mark”, lastName: “Weiss” }] …

Continue Reading

Excel: Need to Generate IDs based on multiple criteria with repeating IDs

July 16, 2021 by Code Error

Posted By: Anonymous Looking to create pricing groups bases on multiple criteria. Each group could have multiple items within the group. I’m struggling with the autocreation the naming of each group. I estimate there should be about 6.5K pricing groups out of 14K items. Below is the criteria – QTY per case – is the …

Continue Reading

Read and write operations Array vs multiple rows in Postgres

July 16, 2021 by Code Error

Posted By: Anonymous If I want to store 10k (sometimes less or more) string values against the same ID multiple times, should I use an array to store those string values or should I insert those string values one by one against the same ID. Solution You can do both but just have a look …

Continue Reading

How to block form submissions if the message field contains certain words (PHP)?

July 16, 2021 by Code Error

Posted By: Anonymous I want to prevent the contact form from submission if the message field contains certain words. I used one, two and three as an example: //Prevent the form from submission if it contains one, two, or three $needle = [‘one’, ‘two’, ‘three’]; if (stripos($message, $needle) !== false) { echo "$message contains $needle"; …

Continue Reading

If object of a nested array in mongodb doesn’t have a field, then display default value

July 16, 2021 by Code Error

Posted By: Anonymous 1.) What I have done I am trying to query over data in MongoDB which looks like this: "AllData": [ { "name": "Company 1", "data": [ { "Brand": "Brand 1", // Brand field present "Product Name": "Product 1", }, { "Brand": "Brand 1", // Brand field present "Product Name": "Product 2", }, …

Continue Reading

Unsigned bytearray to HEX

July 16, 2021 by Code Error

Posted By: Anonymous I’m new to working with bytes and I have to filter out some BLE messages by some values on their Payload (bytearray) According to the documentation of the device I’m working with, the payload 3th and 4th value corresponds to the Company ID. The values I get are [-38, 3] and the …

Continue Reading

2D to 1D numpy array with indices of column for each row

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to index a column for each row in a matrix. Suppose I have a numpy array A with the shape (n,m). I also have a numpy array B with the shape (n,) containing integers between 0 and m, so they can be used as indices for the 2nd axis of …

Continue Reading

How to add array to a specific object in a data?

July 15, 2021 by Code Error

Posted By: Anonymous Here how I’m trying to add some values to my data. The problem is that the tasks add as an object in the same level as parent’s object. Like this: However, I need it to be inside an object. // This is my data const [list, setList] = useState({ home: { title: …

Continue Reading

How to reverse $unwind or re-assemble after $lookup?

July 15, 2021 by Code Error

Posted By: Anonymous I´ve been trying to reverse $unwind in nested array. Please, if you could help me it would be great. Thanks in advance. Here are the details: checklists collection, this collection has steps and each step has many areas, and I’d like to lookup to fill the area by id. I did it …

Continue Reading

How to pass array of objects to asp.net core controller via ajax

July 15, 2021 by Code Error

Posted By: Anonymous I am working on a complex form with different sections that are pulling data from different sources. the form has checkboxes, select options, and input forms. There form has dynamic input fields. So I decided to get all the input fields and serialize has seen in the code below. I was able …

Continue Reading

How to compare 5 different arrays and creating a new array based on the number of the same values in each index

July 14, 2021 by Code Error

Posted By: Anonymous I have 5 different arrays such that: A=[1,0,2,1,1] B=[1,0,1,1,2] C=[1,1,1,1,2] D=[2,0,2,1,1] E=[1,0,2,1,1] the new array will be: final_array=[1,0,2,1,1] So simply, there are four "1" in the first element of the arrays so the first element of the new array will be "1", there are three "2" in the third element of the …

Continue Reading

Append 1d array to multiple dimentional array in Numpy Python

July 14, 2021 by Code Error

Posted By: Anonymous I have [1,2],[5],[2,7,9] and I want to make [[1,2],[5],[2,7,9]]. I tried some commands but they all return [1,2,5,2,7,9]. Can someone help? Thanks Solution l1 = [1,2] l2 = [5] l3 = [2,7,9] new_list = [] new_list = [l1] + [l2] + [l3] print(new_list) # or new_list = [] new_list.append(l1) new_list.append(l2) new_list.append(l3) print(new_list) …

Continue Reading

numpy function to reorder along an axis

July 14, 2021 by Code Error

Posted By: Anonymous Is there an easier way (np function) to achieve the following? bb is the output I’m looking for. import numpy as np aa = np.arange(4*4*3).reshape(4,4,3) bb = np.stack((aa[:,:,2],aa[:,:,1],aa[:,:,0]),axis=2) I don’t think np.roll is applicable here, because it seems to shift sequentially. Solution You could just use -1 as the step argument on …

Continue Reading

Using table on a list of arrays in R

July 14, 2021 by Code Error

Posted By: Anonymous Let’s say I have the following list in R: my_list <- list(structure(c(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, -1, -1, -1, 0), .Dim = c(1L, 25L)), structure(c(0, 1, -1, 0, 1, -1, 0, -1, -1, 1, 1, 1, …

Continue Reading

How to correctly iterate over a JSON stored in state using ReactJS?

July 14, 2021 by Code Error

Posted By: Anonymous I want to iterate over my jsondata to remove elements but I get the following error this.state.jsondata is not iterable. I understand a bit the problem and for what I understand I must iterate over the items inside this.state.jsondatabut I can’t figure out how to fix it. The error appears where I …

Continue Reading

Map over children with top level React Children API

July 14, 2021 by Code Error

Posted By: Anonymous I am trying to render the children in a component by mapping over the children with the React Children API. I can’t figure out why but the children are not renderen import React from "react"; import List from "components/List"; function Artists(): JSX.Element { return ( <List> <p key={"1"}> test1</p> <p key={"2"}>test2</p> <p …

Continue Reading

Reduce function wrapping data in an array

July 14, 2021 by Code Error

Posted By: Anonymous I have a reduce function that formats my data in the way i need but the only issue is the data is nested inside an array. I need to remove the outter array or just stop the reduce function from adding it in but every attempt Ive made to stop the reducer …

Continue Reading

How to check previous inputs in hangman game

July 14, 2021 by Code Error

Posted By: Anonymous I am new to JavaScript and i have project in which I have to make a hangman game. I have already built a function that replace _ with correct answers. If password is "MOM": if you guess M then you have M _ M, if you guess O then you have _ …

Continue Reading

Multidimensional arrays, remove the duplicated array in next array

July 13, 2021 by Code Error

Posted By: Anonymous My arrays result is like this one Array ( [0] => Array ( [id] => Bank Transfer [ec] => 1000 [accounts] => Array ( [0] => Array ( [name] => Account WD [value] => ) [1] => Array ( [name] => Keterangan [value] => ) ) ) [1] => Array ( [id] …

Continue Reading

How do you sort a mongo database by the nth item in an array using node js?

July 13, 2021 by Code Error

Posted By: Anonymous For example the database looks like this { id: 1, counter: [2,6] }, { id: 2, counter: [5,10] }, { id: 3, counter: [1,3] } Now I want to sort it by for example the second item in each array so the result comes out like this { id: 2, counter: [5,10] …

Continue Reading

JavaScript card game: set the player who deals the cards in each hand

July 13, 2021 by Code Error

Posted By: Anonymous I am working on a card game and I need to set the player who deals each hand. I have two arrays, one stores the hands and the other stores the players. hands = [ { handNumber: 1, dealer: null }, { handNumber: 2 dealer: null } … ] players = ["Player …

Continue Reading

Returning array object by filtering it’s nested size variants

July 13, 2021 by Code Error

Posted By: Anonymous I have the list of products that i want to filter by their varriants.size Staring point, data I’m receiving: const t1 = [ { name: ‘Product 1’, variants: [ { size: ‘sm’, sku: ‘1’ }, { size: ‘md’, sku: ‘2’ }, ], }, { name: ‘Product 2’, variants: [{ size: ‘lg’, sku: …

Continue Reading

PowerShell – Append counter to Array variable and use it after

July 13, 2021 by Code Error

Posted By: Anonymous I have the following code: $CompletedCount = 0 $ArrayName1 = @(‘test’,’test1′,’test2′) $ArrayName2 = @(‘test3′,’test4′,’test5’) $Array = 0 while($true) { Write-Host $CompletedCount $CompletedCount =2 if ($CompletedCount -gt 0) { $Array++ $ArrayToDo = "ArrayName{0}" -f $Array Write-Host "Starting with $ArrayToDo" foreach ($Name in $ArrayToDo) { Write-Host $ArrayToDo.Length $Name } Start-Sleep -Seconds 5 }else { …

Continue Reading

Push string into array in struct in solidity

July 12, 2021 by Code Error

Posted By: Anonymous I have a struct in solidity defined as follows: struct Batch{ address payable owner; address payable[] precedentsOwners; uint[] precedentsBatches; } I want to create a function that allows me to append a list of owners to this struct, but i get a lot of errors… Is there any way to do this? …

Continue Reading

How to convert different numpy arrays to sets?

July 12, 2021 by Code Error

Posted By: Anonymous I have one numpy array that looks like this: array([ 0, 1, 2, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 27, 28, 29, 32, 33, 34, 36, 37, 38, 39, 42, 43, 44, 45, 47, 48, 51, 52, 54, 55, 56, 60, 65, 66, 67, …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 56
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error