3

I would like to create the following dataframe without columns names

import pandas as pd
df = pd.DataFrame([0,423,2342],[12,123,1231], [1,3,5])

I get back an error

TypeError: unhashable type: 'list'

What am I doing wrong?

I also tried {}, but it did not help.

df = pd.DataFrame({[0,423,2342],[12,123,1231], [1,3,5]})

1 Answer 1

5

The thing is you should pass your data as a 2D array, otherwise the constructor thinks you've passed several positional arguments.

DataFrame([[0,423,2342],[12,123,1231], [1,3,5]])
Sign up to request clarification or add additional context in comments.

2 Comments

Technically, this is a list of lists.
@chthonicdaemon Yes, technically it's a nested list that is isomorphic to 2D array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.