Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas dataframe Shape of passed values is (1, 4), indices imply (4, 4)

I am trying to create a pandas dataframe with one row using and ended up testing the following simple line of code:

df = pd.DataFrame([1,2,3,4], columns=['a', 'b', 'v', 'w'])

Although this seems very simple i get the following error

Shape of passed values is (1, 4), indices imply (4, 4)

I have seen a few answers on this issues but all provide a way around it that doesn't explain why this happens and does not apply in my case.

Thanks is advance.

like image 577
saias Avatar asked Jun 15 '18 10:06

saias


People also ask

How many indices does a DataFrame have?

But for now here's my answer: DataFrame is 2 dimensional, and its index are rows and columns (2 indexes) .

What is pandas DataFrame shape?

The shape of a DataFrame is a tuple of array dimensions that tells the number of rows and columns of a given DataFrame. The DataFrame. shape attribute in Pandas enables us to obtain the shape of a DataFrame.

What does shape function do in pandas?

Definition and Usage The shape property returns a tuple containing the shape of the DataFrame.

What is 75% in describe pandas?

For numeric data, the result's index will include count , mean , std , min , max as well as lower, 50 and upper percentiles. By default the lower percentile is 25 and the upper percentile is 75 . The 50 percentile is the same as the median.


1 Answers

you need to change the list of values to [[1,2,3,4]]

df = pd.DataFrame([[1,2,3,4]], columns=['a', 'b', 'v', 'w'])
like image 121
nimrodz Avatar answered Oct 23 '22 12:10

nimrodz