Questions tagged [tuples]

In programming, tuples are simple *product types*, representing ordered collections of types.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

How to achieve associated and independent ComboBox on a table in WPF?

I am developing a user interface program that I am managing through DataTables. In the main view I need to show a general table with the data, said table must be editable, only that the first two ...
Emmanuel Solis's user avatar
1 vote
1 answer
42 views

In julia, how to dispatch different kinds of "MutableNamedTuple"

My Julia code uses many different kinds of MutableNamedTuples e.g. box = MutableNamedTuple CSV(file::String) = box(rows=[], file=file) NUM() = box(n=0,mu=0, sd=0, m2=0) I want to dispatch methods ...
Tim Menzies's user avatar
-3 votes
0 answers
20 views

Python help get bug on line 26 - Error is exception (<class 'NameError'>, name 'item' is not defined) [closed]

Here is my current code I keep getting a error on line 26. Has to be a tuple error for item. I just don't know what to do to fix it. Any help would be apricated. # dictionary of rooms and items rooms =...
Hollis Burks's user avatar
1 vote
1 answer
59 views

putting a visualized binary tree into a tuple

i got this binary tree i want to put this in a tuple with the structure (left_subtree, key, right_subtree) (where left_subtree and right_subtree are themselves tuples. how can i do this in a right ...
rezaatb's user avatar
  • 13
-3 votes
1 answer
55 views

How to get sum of nested tuples in list [closed]

I have the list [(270,), (270,)] and I want to add the values in the tuples together. How would I do this? Note: The number of tuples will vary so I need a dynamic solution to add the values together
PRA7H1K's user avatar
  • 117
1 vote
3 answers
71 views

Difference between tuples that may have duplicates

I have two tuples, which may or may not have duplicated elements. I want to remove elements of tuple a that also occur in tuple b, taking into account multiplicity. That is, a = (1, 2, 3), b = (2, 3, ...
rogerl's user avatar
  • 197
1 vote
2 answers
50 views

Expand list of tuples [duplicate]

I have a big list of tuples (20-30 million entries). Each sub-tuple has three pieces of information (start, end, value) and is supposed to only represent one position in a sequence. However, the ...
G_T's user avatar
  • 1,567
-1 votes
2 answers
69 views

python calculation of tuples of two for big n

I'm trying to calculate all possible combinations of pairs in tuples starting from 0 to the length of my file (62977) so i get this result as a single DASK series\data frame with no duplicates: (0,1), ...
Mika Bell's user avatar
-1 votes
1 answer
72 views

Trying to read list of tuples with date-pairs in bash is failing using argparse

I have python script that one of its' parameters is list of tuples: def my_func(my_date_list: list=None, #List of dates to be used. Example for list : [('2017-07-02', '2017-08-15'),('2019-09-02', '...
Reut's user avatar
  • 1,561
0 votes
1 answer
40 views

Tuples in Django models

I want to write the whole word on the website when entering the product information by entering the first letter of the status field. But here it receives the information correctly, but only displays ...
zahra shokrizadeh's user avatar
0 votes
1 answer
24 views

List instead of a Tuple as a return: failed type inference in Numba jit-ted function

I am trying to use numba.jit to compile a function that takes several inputs and returns one Tuple. I specified the types of inputs and output within the jit decoration, thinking that this would have ...
FedeMatte's user avatar
0 votes
0 answers
22 views

Why my indexing works with arrays but not with tuples in Rust [duplicate]

I am totally new to rust and don't have much programming experience either. I want to write a simple game rock, scissors, paper, lizard, Spock and want randomly choose one of them from a tuple which ...
hinode's user avatar
  • 1
0 votes
1 answer
67 views

Compile-time impact of using recursive template implementation for tuples

Several sources, e.g., Why is it not good to use recursive inheritance for std::tuple implementations?, point out the compile-time cost of using recursive template implementation for tuples. I'm ...
TooTone's user avatar
  • 7,291
0 votes
1 answer
24 views

Additional level using MultiIndex.from_tuples in pandas

In my DataFrame I need to have 3 header rows. The header lines are as an example in the attached image. I'm using python, streamlit and pandas. How do I do the levels below? 1a. line header: ColA ColB ...
Ana's user avatar
  • 1
0 votes
1 answer
25 views

How to assign 2 args from Commands in clap to 2 vars?

I was trying to get 2 args from Commands in clap. And I a bit stack with it. Here is my code: use clap::{Parser, Subcommand}; #[derive(Parser, Subcommand)] enum Commands { Remove { name: ...
MarieGosnell's user avatar
0 votes
3 answers
48 views

How can I compare numbers fetched from a database with sqlite3 in Python?

I'm quite new at programming, and I'm working in python with sqlite3, and I have a column where the numbers are ordered, but there might be gaps (1, 2, 4, 7, 8...). What I'm trying to do is to make a ...
Carlos González's user avatar
1 vote
2 answers
53 views

Initializing variadic-template-constructed tuple of types with constructor requiring an argument

I apologize already having asked a similar question here when I should have modified the question I asked first. I have the class Level which constructor requires an argument. Using variadic templates ...
Astor's user avatar
  • 310
0 votes
2 answers
32 views

TryFrom trait for composed tuples

Here's a working solution for part of the rustlings try_from exercise. impl TryFrom<(i16, i16, i16)> for Color { type Error = IntoColorError; fn try_from(tuple: (i16, i16, i16)) -> ...
iHnR's user avatar
  • 135
0 votes
1 answer
74 views

Simplify creation of compile-time binary tree type

In the context of creating a binary tree type for a larger C++ project, I need to create a compile time type representing the nodes in each level. Does anyone know, using the newest standards, if ...
Astor's user avatar
  • 310
0 votes
3 answers
124 views

Find longest interval between overlapping intervals in Python?

I have a list of intervals in the form of tuples such as this: data = [(5,10), (3,10), (13,15), (12,18), (20,29), (25,30)] Each item in the tuple has 2 values (i.e., start, end) and there may or may ...
O.rka's user avatar
  • 30k
0 votes
0 answers
21 views

Numpy: How to get the index of a tuple within an array of tuples using 'where()'

Existing answers for this question all involve tuples of uneven length, which is a problem I don't have, so their solutions are not relevant to me. I have a 1d array of tuples. I want to get the index ...
Thomas Slade's user avatar
-2 votes
0 answers
22 views

Sort Rows Based on Variable Tuple Index [duplicate]

Question: This function is able to solve the problem but only with max length 3. How do I transform this to work with max n? def fn(x): vals = x.sort_values(by='Num', ascending=False) df.loc[x....
Luke Hamilton's user avatar
-2 votes
1 answer
42 views

List user input of a tuple

How do i take a user input this way in Python -> [('a',23), ('b', 37), ('c', 11), ('d', 29)] I tried using this tup = [] line = input("\n") while(line != ''): tup.append(tuple(...
Varan Erranki's user avatar
0 votes
1 answer
40 views

Adventure Story Graph Tuple Bug

I'm working on a practice project dealing with graphs. It's an interactive adventure game where the user inputs choices and tries to escape the wilderness, however, right now, when the user chooses an ...
Sharon Kaufman's user avatar
0 votes
1 answer
28 views

How to iteratively add tuple elements to a dataframe as new columns?

I am using the statsmodels.stats.multitest.multipletests function to correct p-values I have stored in a dataframe: p_value_df = pd.DataFrame({"id": [123456, 456789], "p-value": [0....
user's user avatar
  • 653
0 votes
2 answers
51 views

Reading file and list/tuple iteration

I need to take the data from a file, remove the lines that begin with a comment hash, then read that file into a list. Then convert that list into a list tuples of start times, end times, and step ...
user159's user avatar
1 vote
2 answers
44 views

JavaTuples API - can not deserialize as they do NOT have no args constructor

I am using javatuples as I have to return multiple arguments from few of my methods calls. Everything seem good until I tried to deserialize a jsonString in to a Triplet. Seems the tuples classes(...
CodeBot's user avatar
  • 49
0 votes
1 answer
28 views

Simple way to get data based on column subset from OpenPyXL Worksheet avoiding iterations

Imagine we want part of a dataset based on specific columns, which is on a worksheet by OpenPyXL. ws = openpyxl.load_workbook("example_file.xlsx")["example_sheet"] Is there a ...
Nelson A. Morais's user avatar
3 votes
1 answer
43 views

Unpacking of tuples of varying sizes in Julia

I have a python code here : >>> a, *b , c = (1,2,3,4) >>> a 1 >>> b [2, 3] >>> c 4 >>> Is there a similar facility available with Julia? Same command in ...
Vinod's user avatar
  • 4,176
0 votes
1 answer
93 views

How can I implement a variable length row-based storage in C++?

I am trying to implement a variable-length row-based storage system in C++. The idea is that each row in this storage system should be able to hold data of varying lengths and different types. For ...
Jacob's user avatar
  • 79
1 vote
2 answers
63 views

How can I make a Dataframe from a dict that maps (column, row) index pairs to values?

Using pandas, given this dictionary which has tuples as keys: dictionary = {(a,c): 1, (a,d): 3, (b,c): 2, (b,d): 4} How can I get a dataframe like so? a b c 1 2 d 3 4 I thought about using df.at[] ...
David's user avatar
  • 11
0 votes
0 answers
52 views

Is there a way to pass the first N elements from a variadic template argument to another function c++?

Currently, I would use the following code below that mainly uses tuples to pass the first N variadic template arguments to a function. I was wondering if there would be a more memory-efficient or just ...
Sam Moldenha's user avatar
2 votes
1 answer
85 views

How can I get the first N elements of a tuple c++?

lets say I had a function like the following, how could I get the first n elements of a tuple? template<std::size_t N, class... Ts> void foo(Ts... ts){ std::tuple<Ts...> all_elements(ts....
Sam Moldenha's user avatar
0 votes
1 answer
18 views

How to do a Frequency count on tuples in Python

so i have a df Parsed Clu [('18', 'nummod'), ('years', 'nsubj'), ('of', 'prep'), ('age', 'pobj'), ('or', 'cc'), ('older', 'conj'), ('with', 'prep'), ('resectable', 'amod'), ('pancreatic', 'amod'), ('...
Divyansh Kumar Singh's user avatar
0 votes
1 answer
35 views

How to output a specific attribute from a map within a map while having an attribute substring as conditional in terraform?

Objective: Using Terraform 1.3.5 and the latest AzureRM provider version, assign a (dynamic) subnet ID to a VM NIC but only when the subnet's name = "all" Main premise: the subnet name is ...
rofz's user avatar
  • 97
0 votes
0 answers
6 views

num1 = "3.2, 2.4, 99.8" list1 = tuple(float(i) for i in num1.split(",")) But when I execute it, it shows 'generator' object is not callable

num1 = "3.2, 2.4, 99.8" tupl1 = tuple(float(i) for i in num1.split(",")) But when I execute it, it shows 'generator' object is not callable. When using this explanation: num1 ...
Yuor Sun's user avatar
1 vote
2 answers
34 views

Split the string in a certain way

I have a string: 50 5 10 4 48 34 Where each value corresponds to the following notation scheme: x1 y1 x2 y2 x3 y3 that is, it means that: x1 = 50 y1 = 5 etc. At the input, a numeric string ...
Дмитрий Насонов's user avatar
0 votes
0 answers
20 views

Adding (concatenating) tuples to lists in Python [duplicate]

In Python3, let me define simple a list and tuple as follows: In [1]: alist = [1, 2, 3] In [2]: atuple = (4, 5, 6) If I attempt an "add" (+) of the tuple to the list and assign that to the ...
Lee McNally's user avatar
0 votes
2 answers
37 views

How to access elements inside a list and store them as new columns in the dataframe?

I have the following dataframe df keywords [(caused patient, 0.4807), (wa non, 0.1332), (2021, -0.0076)] [(incorrect reconstitution, 0.9084), (error, 0.5304), (incorrect, 0.2877)] The column name ...
brins's user avatar
  • 1
1 vote
2 answers
77 views

How to convert a tuple of dictionaries of pyTorch tensors into a dictionary of tensors?

I have a tuple of dictionaries, that hold pyTorch tensors: tuple_of_dicts_of_tensors = ( {'key_1': torch.tensor([1,1,1]), 'key_2': torch.tensor([4,4,4])}, {'key_1': torch.tensor([2,2,2]), '...
AlonBA's user avatar
  • 444
0 votes
0 answers
40 views

Converting DTO to model. How to get values fromTupleConverter$TupleBackedMap

Hi I'm trying to get specific values from a jpa repo class. By creating a interface class and appending with get methods. But I couldn't get values from it. I can see the values in debug mode. But ...
S14321K's user avatar
  • 220
0 votes
0 answers
42 views

How to use ValueTuple/Tuple as value and make it mutable in Dictionary? [duplicate]

I want to use ValueTuple or Tuple in Dictionary together and to be able to change content/variable. But it says Cannot modify the return value of because it is not a variable Actually, I want to be ...
livan3li's user avatar
  • 129
0 votes
1 answer
23 views

Is there a way to make it a type inference of an array imported as a splice function from different types of tuples?

For example, let's say there's a code below. type MyType = 'a' | 'b' | 'c'; const a = [3, 5, 'a', 'b'] as const; const func = (arg: readonly [number, number, ...MyType[]]) => { const ...
dom wis's user avatar
  • 27
0 votes
0 answers
29 views

Why i am getting the 'Type error' as 'tuple object is not callable' [duplicate]

# Predict from the test dataset prediction1 = svn.predict(X_test) # Calculate the accuracy from sklearn.metrics import accuracy_score accuracy=(accuracy_score(y_test,prediction1)*100) print("The ...
Soumyajit Das's user avatar
-1 votes
1 answer
50 views

Connect 4 Python Code, my diagonal check is not working, what am I doing wrong here?

I have been given a 2D tuples that should be seen as Connect4 game. Mt code should detect that there are 4 X's in the first tuple diagonally and 4 O's horizontally in the second tuple. I have been ...
Space88's user avatar
-1 votes
5 answers
54 views

Python combinations between 3 lists with one depending on one list

I have two lists and a third list that depends on the first one. l1 = [1, 2] l2 = [3, 4] l3 = [[11, 111], [22, 222]] # the numbers are calculated for each element of l1 What I would like is to ...
CornelioQuinto's user avatar
17 votes
1 answer
529 views

Inconsistent behavior of std::common_reference_with on tuples. Which is correct?

Background: I'm trying to port a library to compile on MSVC. That library stores data in a tuple of vectors (std::tuple<std::vector<Ts>...>), and uses a custom iterator to iterate over all ...
Panagiotis Syskakis's user avatar
0 votes
1 answer
28 views

TypeError: 'tuple' object is not callable; range function

x = range(0, 10, 1) print(x) Traceback (most recent call last): Cell In[29], line 1 x = range(0, 10, 1) TypeError: 'tuple' object is not callable I don´t sleep for over 24h and now I think I´...
Miguel Guerreiro's user avatar
3 votes
1 answer
120 views

Explicitly infer tuple type

Typescript version: 5.1.6 Here is a minimal reconstruction of my problem: I have a function f which is gonna take an array of C where declare class C<a = unknown, b = unknown> { getA(): a; ...
Hello Hello's user avatar
0 votes
0 answers
31 views

Typing Tuple when using as default argument

I have a case where I would like users of our package to be able to select from a list of options, for example run_package(some_settings=("setting_1", "session_2", "setting_3&...
Joseph's user avatar
  • 578

1
2 3 4 5
240