Skip to main content

All Questions

Tagged with
3 votes
1 answer
685 views

How to initialize an array with NamedTuples in Julia 1.6.0?

I can initialize an array of tuples with Array{Tuple{Int, Int}}(undef, 10). However, I cannot make it work for named tuples. Does anyone know how I can do this? Thanks in advance!
Babypopo's user avatar
  • 151
0 votes
1 answer
45 views

Can I use `namedtuple` to give names to the elements of a 1D array?

res.x is an array I obtained by optimizing an objective function, and I want to give each element a name so I can use them more conveniently later. My initial idea is to use namedtuple, but apparently ...
Paw in Data's user avatar
  • 1,432
1 vote
1 answer
4k views

Writing a numpy.array() from a list of namedtuples

I have a list of namedtuples which I would like to write to a numpy array. The tuples have attributes 'colors', a set of two colors, and 'number', an integer, and are of the form: from collections ...
Zero's user avatar
  • 33
-1 votes
1 answer
45 views

Returning Max value grouping by N attributes

I am coming from a Java background and learning Python by applying it in my work environment whenever possible. I have a piece of functioning code that I would really like to improve. Essentially I ...
whatafarce's user avatar
3 votes
1 answer
263 views

How to init an array of named tupples in swift

I'm trying to create and array of named tuples. But when i'm calling the array constructor with the following line : var test:[(test1:Int, test2:Int)] = [test1:Int, test2:Int](count: 12, ...
Loadex's user avatar
  • 1,502
1 vote
2 answers
2k views

initialize numpy array with named tuples

I'm trying to initialize a NumPy array that contains named tuples. Everything works fine when I initialize the array with empty data and set that data afterwards; when using the numpy.array ...
Nico Schlömer's user avatar
0 votes
3 answers
330 views

Which data structure to use as an array of dicts?

I need to build a data structure like this one: { key: {k: v for k in range(fixed_small_number)} for key in range(fixed_large_number) } The thing is I'm building it in an "eclectic" way, ...
phistakis's user avatar
  • 221
2 votes
1 answer
6k views

Python how to edit data in a namedtuple stored in a list?

import struct from collections import namedtuple StructPageNum = namedtuple('FDResult', ['DeviceID', 'PageNum','PicSize','PicData']) PageNumList = [] Node = StructPageNum(DeviceID='NR09', PageNum=[],...
user avatar
3 votes
1 answer
2k views

Python namedtuple slice

this is my first question here... if I have a namedtuple like the below FDResult = namedtuple('FDResult', ['S', 'Payoff', 'V']) and I have an array that has a collection of namedtuple like the ...
pacifictoy's user avatar