Studying Pandas Style , I realized the following:
def highlight_max(s): ''' highlight the maximum in a Series yellow. ''' is_max = s == s.max() return ['background-color: yellow' if v else '' for v in is_max]
How to read is_max = s == s.max()?
is_max = s == s.max()
s == s.max()will be computed before boolean (due to ==between variables). The next step is to save this value in is_max.
s == s.max()
==
is_max
The code
estimated as
is_max = (s == s.max())
First, the bit in parentheses is evaluated, and this is either True, or False. The result is assigned is_max.
True
False
pandas s Series ( DataFrame).
s
Series
DataFrame
, Series max Series . is_max. 'background-color: yellow' , True - .
max
'background-color: yellow'
:
s = pd.Series([1,2,3]) print (s) 0 1 1 2 2 3 dtype: int64 is_max = s == s.max() print (is_max) 0 False 1 False 2 True dtype: bool
is_max EQUAL s s_max
, .
, , .
, Python s.max(), , s, , is_max.
s.max()
. :
Source: https://habr.com/ru/post/1657494/More articles:How to connect to Oracle database using Node Js in a Windows machine - windowsHow to check if a list of objects contains a line with a timemeaf? - javaHow to set Java class path in bash script used in Ubuntu and Windows (Cygwin) - javaes6 уникальный массив объектов с множеством - javascriptМодуль SOAP:: Lite Perl отправляет неправильное пространство имен конвертов SOAP - soapHow to get linux ebpf build? - assemblyЯвляется ли хорошей практикой издеваться над Automapper в модульных тестах? - c#Validating WSO2 API Manager through a Single Page Application - wso2Link to python file in Jupyter notebook markup cell - jupyter-notebookHow to implement an array of volatile elements - javaAll Articles