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]})
user1700890
  • 7,144
  • 18
  • 87
  • 183

1 Answers1

4

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]])
Eli Korvigo
  • 10,265
  • 6
  • 47
  • 73