Questions tagged [map-function]
Higher-order function "map" transforms a collection by applying a given function to each element in it. USE [maps] for geography, [map] or [dictionary] for data types.
828
questions
1
vote
1
answer
18
views
TypeError: data.map is not a function in react and django
I'm using Axios to retrieve data from the backend. When I log the data to the console, it appears as an object. However, I need the data to be in an array format. When I try to use the map function on ...
0
votes
1
answer
18
views
is map function is not working in next js 13.4.17 or above
i am using next js 13.4.19. i have made a GET api and trying to access the data available at mongodb database. but when i try to map the data it shows me error
Error: data?.map is not a function.
This ...
1
vote
1
answer
37
views
how to change value on nested list use map function in R
Need help I have nested list, I would like to change all the value of the photo become empty list, the list are below :
df <- list(messaging = list (telegram = list (registered = 'true', photo = c(...
0
votes
1
answer
24
views
React .map doesn't work while trying to set data for displaying on the chart
I want to display data from API on the chart and I know how to do it but I have error while using .map function. I want to separate prices[0]from prices [1] to have access to two of them because my ...
0
votes
1
answer
21
views
How to return the correct data in a map() function in react-native
When I input data into my Text input, it goes into this array
WorkoutItems([...workoutTextItems, workoutText, setsText])
I want to get my data individually from each item, so for example, workoutText ...
0
votes
1
answer
19
views
How to get unique and returning users count from overall user enteries with a user key in couchDB
I have a key called 'username' that stores the user logic records with a unique user id in couchDB. Now I want to get unique users count and returning users count from those records with the help of ...
0
votes
1
answer
64
views
why is it consoling an empty array?
const testFolder = '../assets';
const fs = require('fs');
const array=[]
const pattern=/gif/
fs.readdir(testFolder, (err, files) => {
files.map(file => {
if(file.search(pattern)>0)
...
0
votes
0
answers
11
views
how to store values in two separate lists if given in same line in python
are there any ways to take inputs of all the values in single line but store some of the values in one list and some in other.
eg. l1 and l2 are two lists and 6 integer values (for say 1,2,3,4,5,6) ...
1
vote
3
answers
58
views
Mapping Array of Arrays into a List
I have an Array of answers, sorted by the question they belong to, like this:
sortedAnswers= [[Answer1, Answer2, Answer3, Answer4],[AnswerA, AnswerB, AnswerC, AnswerD]...]
I'm trying to render a ...
0
votes
2
answers
54
views
Map an Array of Arrays of Objects [closed]
I'm trying to map the text of a database of given asnwers in a List for my quiz App.
The problem is that i have to acces the title in an array of array of objects like this:
log of the database in ...
0
votes
0
answers
17
views
How to map different values for classification to binary with LIME?
I use a dataset for white Whine and one column "Quality" of it for classification purpose. I want to map the results 4 and 5 as "bad" and 6 to 8 as "good" classification. ...
0
votes
2
answers
69
views
How do i capitalize the first letter of each sentance in Javascript? [duplicate]
How do i capitalize the first letter of each sentance in Javascript?
(I am creating a tool that would convert first letter of each sentance to upparcase(Sentance Case) on click in reactjs)
I want ...
5
votes
2
answers
130
views
Use Map function with the base R pipe |>
How can I use the Map function with the pipe base |>?
The next x vector can be used inside the Map function
x <- c(1,5,1,2)
Map(function(n)n*2, x) |> unlist()
# [1] 2 10 2 4
This works, ...
-4
votes
1
answer
31
views
Hey Guys i have a problem in my react class base component by using the setstate please anyone solve this error [duplicate]
This is my and i am trying to fetch api and show the result in my next react component but if i can set the state in the componetmountfunction it can cause the error. !this.state.articles.map is not a ...
0
votes
2
answers
65
views
Python multiprocessing issue with passing multiple variables / global variables into function
When I run the code below, the global variable 'ticker' is not defined in the compile() function.
Goal: How do I pass multiple variables into the multiprocessing pool.map() function to make this code ...
1
vote
1
answer
33
views
Condition rendering of photo using map
I'm trying to render a specific photo based on the input from a user. I map over the users information and get all the fields right except the img field where I try to add a conditional statement.
...
0
votes
0
answers
26
views
Random yet balanced assignment of a binary variable with a map function
I am quite new to R and struggle with assigning a binary variable (domain; which can either be "social" or "analytical") to every row in my dataframe. I need it to add another ...
1
vote
2
answers
74
views
How releve model within map function in dplyr
I have the following dataset
dput(dat2)
structure(list(g = c("Women", "Women", "Women", "Women", "Women",
"Women", "Women&...
0
votes
1
answer
85
views
cannot use the map function on nested dataset
I have the following dataset
# dput(head(dat, 130))
dat <- structure(list(
Gender = c("Women", "Women", "Women", "Women", "Women", "Women&...
0
votes
0
answers
20
views
independently update the state of a attribute of a item in an array which are return using map
this is my entire code
import { FormButton } from "../../shared/SharedElements/Buttons";
import { Header } from "../../shared/SharedElements/SharedElements";
import \* as l from './...
0
votes
0
answers
95
views
Using 'get multiple variables' tool in make.com not outputting the variables anywhere
I have successfully used this tool to take multiple variables from a previously aggregated array, however there is no output on the module to use any of the variables further down the line.
Any idea ...
0
votes
1
answer
168
views
Cant acces array[0] of rows returned by exceljs
this is my first question and I hope someone can help me, I need to convert an excel to json to upload the data to a DB with Angular and exceljs, I've been trying a lot of things but I could not find ...
1
vote
1
answer
89
views
How to use map with a list of lists
I am needed to use map on a list of lists in Scheme (Racket).
What I want specifically is something like (map-lists add1 '((3 1) (2 8))) => '((4 2) (3 9)).
I know how to solve this recursively, ...
1
vote
1
answer
52
views
TensorFlow Dataset - how to make map function return multi columns as one tensor
Question
How to write a map function that generates a TensorFlow dataset where each row is a multi column tensor?
Problem
Here is a dataset.
import tensorflow as tf
dataset = tf.data.Dataset....
1
vote
2
answers
567
views
How to use <br> Tag within React map function loop
I loop through an Array of objects in ReactJS where I use map function to loop through each Object. So Can i use tag to separate each objects in next line. I tried to put a tag at the end of the ...
0
votes
2
answers
51
views
map through list stored in state - react
I'm trying to map through a list that is stored in the state and pass each item in the list as a prop to another component. Here is what it looks like. The video component is supposed to receive each ...
0
votes
1
answer
25
views
Limit mapped items in a loop [duplicate]
I've searched other posts but couldn't quite find I was looking for. I am looping through data from a sanity api but I want to limit it to just the first 4 items returned. What would be the best way ...
0
votes
1
answer
379
views
Proper way to return a map function
I have the map function.
function test2() {
let data = [
["a","aa","aaa"],
["b","bb","bbb"],
["x&...
0
votes
3
answers
147
views
Python How to pass specific key from list of Dictionary to Map function
I have data in below format:
and I have function which accepts 2 keyword argument
I am unable to come with syntax or example where i can pass specific keys from list of dictionaries to Map function ...
0
votes
2
answers
65
views
Python: Call function that returns two strings inside map function
Hello I am trying to create a function that is called inside a map function, splits the string that have been passed as input and returns two processed strings. To be more understood here is my code (...
0
votes
1
answer
49
views
"Key" prop in map
Newbie here, Sorry for the silly question :)
How am gonna put the "Key" prop in this function?
The code is on the above of ContactShadows. I tried many ways but all the methods I tried are ...
0
votes
2
answers
341
views
Using Map function inside of another Map function in React Js
I want to add genre to my Movie Search app's carousel using map function. I have two json files one of them is an array of movie data as objects having a key as genre_ids eg:
genre_ids: 0: 16 1: 28 2:...
0
votes
1
answer
112
views
Add Search functionality using a input search field state in ReactJS
I have made a ReactJS application to display the items from a restaurant menu by making use of an API.
My API data is in this way:
[
{
"Name": "Chicken pizza",
"...
1
vote
2
answers
70
views
reduce and map: how to get the same results
I am using a reduce and my code works correctly, however, I was trying out using a map, but not sure how to implement it. Any help would be appreciated.
What does the program do?
Below I am fetching ...
0
votes
1
answer
353
views
Function scatter_mapbox returns only blank maps. How to solve it?
I'm trying to use the function "scatter_mapbox" from plotly.express and everything I get back are blank maps. I'm having this issue in Jupyter Notebook with Python 3.9.12. I have tried to ...
1
vote
0
answers
136
views
Using a map() function as a condition
I have two DataFrames, one gets daily new inputs via Id number and gives the related value. The other one corresponds to a "catalog" that lists all existing Ids and outputs the name of the ...
0
votes
1
answer
67
views
Save csv files using filenames in a map function loop
I am looping a number of csv files in a folder using the map function. I want to save the results of the loop using a sliced version of the name of the csv. But I am getting an error when attempting ...
-2
votes
1
answer
23
views
How to convert this loop to a map?
How could i get the same result with a map? i'm a beginner trying to learn how maps relate to iteration. Is it possible to put this loop into a map?
user_list = [int(input("what is the fist ...
0
votes
0
answers
27
views
Trying to use the state variable declared in a map function in React
const [measure, setMeasure] = useState("us");
{recipe.map((d) => {
return (
<ul>
<li>
{d.measures.${measure}.amount}{d.name}
...
1
vote
1
answer
44
views
Pyspark lambda operation to create key pairs
I already have code which maps to this
['vita', 'oscura', 'smarrita', 'dura', 'forte', 'paura', 'morte', 'trovai', 'scorte', 'v’intrai']
I want this
[('vita','oscura',1),('oscura','smarrita',1),('...
0
votes
1
answer
242
views
Python map() function with an existing list [duplicate]
might be a dumb question but why when I try to use map() function on an already existing list:
nums = [1,2,3,4,5]
result = map(lambda num: num+num , nums)
print(result)
it returns me: <map object ...
0
votes
0
answers
8
views
type error regarding promise.all with the map [duplicate]
router.post('/', async (req, res) => {
const orderProductsId = await Promise.all(req.body.orderProducts.map(async (orderproduct) =>{
let neworderProduct = new OrderProduct({
...
0
votes
1
answer
32
views
map function is not display anything
The code is related to singly linked list,I am trying to display a value of a singly linked list using map function and state in react js.
the function logic() is to update state when display button ...
-1
votes
1
answer
233
views
Use map function to validate each input and create border around the input which is invalid or empty on button click
i am working on a form which has multiple steps so in each step when i click next it validate the current active step page with map function.
i want to achieve Use map function to validate each input ...
-1
votes
3
answers
442
views
how to check a condition in object array [closed]
I am trying to use an array map for checking if same username and password exist in an object array
database.map((obj)=>{
if(values.name === obj.name && values.password===obj.password){
...
0
votes
1
answer
45
views
ReactJS map: Expected an assignment or function call and instead saw an expression - no-unused-expressions
I'm in the midst of cleaning up errors for a repo and I've come across this error where someone's trying to to assign a tag value object to a const variable inside of a map function. Here's its ...
0
votes
2
answers
34
views
Cannot reach datas details with map function
function Clothes() {
const { loading, error, data } = useQuery(GET_CLOTHES);
const [products,setProducts] = useState([]);
const [index,setIndex] = useState(0)
useEffect(() => {
if (...
0
votes
1
answer
44
views
in map function why I cannot reach all elements?
Hello everyone I have function like that.When I tried to call my datas I can just reach to first index of each array.For example I have 5 different pictures of playstation but on my web page I just ...
0
votes
0
answers
35
views
The return type 'List<DataRow>' isn't a 'DataRow', as required by the closure's context
`
DataTable(
showBottomBorder: true,
columnSpacing: 60,
border: TableBorder.symmetric(inside: const BorderSide(width: 1.0, color: ...
0
votes
0
answers
263
views
Mui grid is causing last two elements of an array to show up larger, and will not display side by side card grid
I have implemented an MUI card grid to display contents of my infinite scroll. However, the last two elements of the returned contents are showing up larger for some reason. Also the grid wont display ...