Repository: databricks/koalas

Issue:
BUG: Index setter is not working when `None` is assigned to `name`
with Pandas:
```python
>>> idx = pd.Index([1, 2, 3], name='a')
>>> idx
Int64Index([1, 2, 3], dtype='int64', name='a')
```
if set name to `None` as below:
```python
idx.name = None
```
then idx will turn to 
```python
Int64Index([1, 2, 3], dtype='int64')
```
but in Koalas, this will raise an error, e.g. 
```python
kdf = ks.DataFrame({"a": [1,2,3], index=pd.Index([1, 2, 3], name='a')})
kidx = kdf.index
kidx.name = None
AssertionError
```



Discussion:
Good catch 😄 
Are you interested in fix this bug? if not, maybe i can handle it.
haha, you are pretty aggressive on issues!! 👍 
But pls feel free to go fix it if you want! @itholic 
in my case, it raises `AssertionError` rather than `ValueError` like

```python
>>> kidx.name = None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/haejoonlee/Desktop/git_store/koalas/databricks/koalas/indexes.py", line 162, in name
    self.names = [name]
  File "/Users/haejoonlee/Desktop/git_store/koalas/databricks/koalas/indexes.py", line 179, in names
    self._kdf._internal = internal.copy(index_map=list(zip(internal.index_columns, names)))
  File "/Users/haejoonlee/Desktop/git_store/koalas/databricks/koalas/internal.py", line 700, in copy
    column_index=column_index, column_index_names=column_index_names)
  File "/Users/haejoonlee/Desktop/git_store/koalas/databricks/koalas/internal.py", line 420, in __init__
    for index_field, index_name in index_map), index_map
AssertionError: [('a', (None,))]
```

maybe is this an another issue??
ah! sorry about this, this is my bad!

mine is the same, i didn't copy paste the whole error message but simply put a `ValueError` to tell this is not working. I will change it in the issue description. Thanks!

Resolving patch:
diff --git a/databricks/koalas/indexes.py b/databricks/koalas/indexes.py
--- a/databricks/koalas/indexes.py
+++ b/databricks/koalas/indexes.py
@@ -174,7 +174,8 @@ def names(self, names: List[Union[str, Tuple[str, ...]]]) -> None:
         if len(internal.index_map) != len(names):
             raise ValueError('Length of new names must be {}, got {}'
                              .format(len(internal.index_map), len(names)))
-        names = [name if isinstance(name, tuple) else (name,) for name in names]
+
+        names = [name if isinstance(name, (tuple, type(None))) else (name,) for name in names]
         self._kdf._internal = internal.copy(index_map=list(zip(internal.index_columns, names)))
 
     @property


Test patch:
diff --git a/databricks/koalas/tests/test_indexes.py b/databricks/koalas/tests/test_indexes.py
--- a/databricks/koalas/tests/test_indexes.py
+++ b/databricks/koalas/tests/test_indexes.py
@@ -107,6 +107,12 @@ def test_index_names(self):
         self.assertEqual(kidx.names, pidx.names)
         self.assert_eq(kidx, pidx)
 
+        pidx.name = None
+        kidx.name = None
+        self.assertEqual(kidx.name, pidx.name)
+        self.assertEqual(kidx.names, pidx.names)
+        self.assert_eq(kidx, pidx)
+
         with self.assertRaisesRegex(ValueError, "Names must be a list-like"):
             kidx.names = 'hi'
 
@@ -128,6 +134,10 @@ def test_multi_index_names(self):
         pidx.names = ['renamed_number', 'renamed_color']
         kidx.names = ['renamed_number', 'renamed_color']
         self.assertEqual(kidx.names, pidx.names)
+
+        pidx.names = ['renamed_number', None]
+        kidx.names = ['renamed_number', None]
+        self.assertEqual(kidx.names, pidx.names)
         if LooseVersion(pyspark.__version__) < LooseVersion('2.4'):
             # PySpark < 2.4 does not support struct type with arrow enabled.
             with self.sql_conf({'spark.sql.execution.arrow.enabled': False}):