0

Let's say I counted the number of rows in a pandas dataframe. I use the following code to do that:

df.shape

It gives me the following result: (1700, 12)

How do I add the 1700 value to an existing pandas dataframe? We'll call the column associated with that value D.

Current dataframe:

A    B   C
30   40  text

Desired dataframe:

A    B   C       D
30   40  text    1700
Ami Tavory
  • 71,268
  • 10
  • 134
  • 170
PineNuts0
  • 4,050
  • 16
  • 57
  • 93

1 Answers1

0

you store your shape in a variable of type tuple and then you create a new column and paste the first value of the tuple

tab = df.shape

df['D'] = tab[0]
youssef mhiri
  • 123
  • 3
  • 11