Top "Namedtuple" questions

namedtuple is a data structure provided by the Python collections module.

How to cast tuple into namedtuple?

I'd like to use namedtuples internally, but I want to preserve compatibility with users that feed me ordinary tuples. from …

python python-3.x namedtuple
Mapping result rows to namedtuple in python sqlite

I am playing a bit with the python api for sqlite3, i have a little table for store languages with …

python sqlite namedtuple
Python list of named tuples, replacing attributes

Here is some simplified code that I don't understand why it does not work. from collections import namedtuple MyStruct = namedtuple(…

python list namedtuple
What is the simple way to merge named tuples in Python?

I want to merge two namedtuples without loosing the key names. If, I just do a merge with '+' …

python namedtuple
Python syntax for namedtuple inside a namedtuple

Is it possible to have a namedtuple inside another namedtuple? For example: from collections import namedtuple Position = namedtuple('Position', 'x …

python python-3.x namedtuple
Pretty print namedtuple

I tried pprint from pprint, but its output is just one line, there is no multiline output and no indentation.

python namedtuple pprint
Python: Copying named tuples with same attributes / fields

I am writing a function that takes a named tuple and must return a super set of that tuple. For …

python namedtuple
Modifying a namedtuple's constructor arguments via subclassing?

I want to create a namedtuple which represents the individual flags in a short bitfield. I'm trying to subclass it …

python new-operator super namedtuple
NamedTuple to Dataframe

I am working on retrieving metadata from youtube channels and it's videos. Everything is going fine, but currently I am …

python pandas dataframe namedtuple
searching a namedtuple like a dictionary

to conserve memory & avoid redundant DB storage (yes possibly pre-optimizing), I'm using namedtuple instead of dictionary. But I need …

python search namedtuple