Version 0.17.1 (November 21, 2015)
=
df
.
style
.
background_gradient
(
cmap
=
"viridis"
,
low
=
0.5
)
|
1
|
1.651437
|
-2.426679
|
-0.428913
|
1.265936
|
-0.86674
|
|---|
|
2
|
-0.678886
|
-0.094709
|
1.49139
|
-0.638902
|
-0.443982
|
|---|
|
3
|
-0.434351
|
2.20593
|
2.186786
|
1.004054
|
0.386186
|
|---|
|
4
|
0.737369
|
1.490732
|
-0.935834
|
1.175829
|
-1.253881
|
|---|
|
5
|
-0.637752
|
0.907105
|
-1.428681
|
-0.140069
|
-0.861755
|
|---|
|
6
|
-0.255619
|
-2.798589
|
-1.771533
|
-0.699877
|
0.927462
|
|---|
|
7
|
-0.173636
|
0.002846
|
0.688223
|
-0.879536
|
0.283627
|
|---|
|
8
|
-0.805367
|
-1.727669
|
-0.3909
|
0.573806
|
0.338589
|
|---|
|
9
|
-0.01183
|
2.392365
|
0.412912
|
0.978736
|
2.238143
|
|---|
"A"
]
.
astype
(
"category"
)
# shows the '+' as we have object dtypes
df
.
info
()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 A 1000 non-null object
1 B 1000 non-null category
dtypes: category(1), object(1)
memory usage: 9.0+ KB
# we have an accurate memory assessment (but can be expensive to compute this)
df
.
info
(
memory_usage
=
"deep"
)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 A 1000 non-null object
1 B 1000 non-null category
dtypes: category(1), object(1)
memory usage: 59.9 KB
2 b
3 b
Length: 4, dtype: category
Categories (2, object): ['a', 'b']
s
.
str
.
contains
(
"a"
)
Out[11]:
0 True
1 True
2 False
3 False
Length: 4, dtype: bool
date
=
pd
.
Series
(
pd
.
date_range
(
"1/1/2015"
,
periods
=
5
))
.
astype
(
"category"
)
date
Out[13]:
0 2015-01-01
1 2015-01-02
2 2015-01-03
3 2015-01-04
4 2015-01-05
Length: 5, dtype: category
Categories (5, datetime64[ns]): [2015-01-01, 2015-01-02, 2015-01-03, 2015-01-04, 2015-01-05]
date
.
dt
.
day
Out[14]:
0 1
1 2
2 3
3 4
4 5
Length: 5, dtype: int32