# What is size-mutable as per Python's pandas DataFrame class?

## Question:

What does size-mutable mean, in this context?

“Two-dimensional size-mutable, potentially heterogeneous tabular data

structure with labeled axes (rows and columns). Arithmetic operations

align on both row and column labels. Can be thought of as a dict-like

container for Series objects. The primary pandas data structure”

from: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html

I presume it means the size is mutable–the size can be changed. Is this correct?

## Answers:

You are right. Size mutable refers that elements can be appended or deleted/pop-ed from a DataFrame. On the contrary a Series is Size immutable, which means once a Series object is created operations such as appending/deleting which would change the size of the object are not allowed.

```
>>> s
a 4.0
b 4.0
c 8.0
d 9.0
f NaN
dtype: float64
>>> s.shape
(5,)
>>> s.drop('f',inplace=True)
>>> s
a 4.0
b 4.0
c 8.0
d 9.0
dtype: float64
>>> s.size
4
>>> s['f']=9
>>> s
a 4.0
b 4.0
c 8.0
d 9.0
f 9.0
dtype: float64
>>> s['g']=200
>>> s.size
6
```

Please go through the above Python commands that imply that Pandas Series are also size mutable.

The size of given series is initially 5.

Then I delete one element `s.drop('f',inplace=True)`

, so the size of the Series will be 4.

Then I again assign a new variable `s['f']=9`

and `s['g']=200`

, then the size of the Series is 6 now.