To create a pandas dataframe with a header I can do:
df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6]})
a b
0 1 4
1 2 5
2 3 6
How would I create one without a header, something like:
df = pd.DataFrame([[1,2,3],[4,5,6]])
0 1 2
0 1 2 3
1 4 5 6
# seems to create three headers, '0', '1', and '2' for the index of the array.
Use zip to interpret the lists as columns instead of lines (if that is your question):
df = pd.DataFrame([*zip([1,2,3],[4,5,6])])
df
>> 0 1
0 1 4
1 2 5
2 3 6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With