Simply pass the desired value as first argument, like 0
, math.inf
or, here, np.nan
. The constructor then initializes and fills the value array to the size specified by arguments index
and columns
:
>>> import numpy as np
>>> import pandas as pd
>>> df = pd.DataFrame(np.nan, index=[0, 1, 2, 3], columns=['A', 'B'])
>>> df.dtypes
A float64
B float64
dtype: object
>>> df.values
array([[nan, nan],
[nan, nan],
[nan, nan],
[nan, nan]])