If I remember correctly, in Stata nan
are displayed as .
. Displaying them as such is particularly helpful if you have a lot of missing values as it draws emphasis to the filled values rather than the reverse. Is there any option in Pandas for an alternative nan
display?
x = (pd.DataFrame(np.random.rand(10,5)) * 100).round()
x[x>10] = np.nan
x
0 1 2 3 4
0 NaN NaN NaN NaN NaN
1 NaN NaN NaN 1.0 5.0
2 NaN NaN NaN 0.0 NaN
3 1.0 NaN NaN NaN 9.0
4 NaN NaN NaN NaN NaN
# Preferably a parameter that set this functionality:
x.fillna('.')
0 1 2 3 4
0 . . . . .
1 . . . 1 5
2 . . . 0 .
3 1 . . . 9
4 . . . . .
You can use Pandas styling, as shown here
df.style.set_na_rep(".")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With