14,962
edits
| Line 172: | Line 172: | ||
=== is null === | === is null === | ||
Fill 0 if the value is NA or NULL | |||
* MySQL SQL syntax: {{kbd | key = SELECT COALESCE(column_name, 0) }} | * MySQL SQL syntax: COALESCE(): {{kbd | key = SELECT COALESCE(column_name, 0) }} or {{kbd | key = SELECT COALESCE(column_name, 'other_filled_value') }} | ||
** (1) Using [http://www.w3resource.com/mysql/comparision-functions-and-operators/coalesce-function.php COALESCE() function] to replace the NULL value with 0. | ** (1) Using [http://www.w3resource.com/mysql/comparision-functions-and-operators/coalesce-function.php COALESCE() function] to replace the NULL value with 0. | ||
** (2) The case: 0/0 = null should be handled. | ** (2) The case: 0/0 = null should be handled. | ||
* MySQL SQL syntax: combined IF() & ISNULL():{{kbd | key = SELECT IF(ISNULL((column_name), 0, column_name}} or {{kbd | key = SELECT IF(ISNULL((column_name), 'other_filled_value', column_name)}} | |||
* python: [http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.fillna.html pandas.DataFrame.fillna — pandas 0.16.0 documentation] "Fill NA/NaN values using the specified method" | * python: [http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.fillna.html pandas.DataFrame.fillna — pandas 0.16.0 documentation] "Fill NA/NaN values using the specified method" | ||