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
  • 74,578
  • 11
  • 141
  • 185
PineNuts0
  • 4,740
  • 21
  • 67
  • 112

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
  • 133
  • 3
  • 11