-1

designing an application I am looking for the best datastructure that should be used for passing 2D arrays between pure functions.

I would like them to be, by decreasing order of preference:

  • immutable
  • preferably from the native Python library
  • easily converted to Pandas Dataframe which will be used in most (but not all) functions
  • enabling fast execution (read) times.

Right now I am leaning towards tuple of tuples:

data=(("header a", "header b", "header c"), (1, 2, 3), (2, 3, 5))

but the idea of converting them to pandas dataframe like this:

df = pd.DataFrame(data=data[1:], columns=data[0])

does not quite feel the most Pythonic.

What would be the best "There should be one-- and preferably only one --obvious way to do it."?

1 Answer 1

1

Use immutable numpy arrays.

Immutable, fast, de facto standard python library for numeric arrays, works well with Pandas...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.