We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Document all the methods in Metadata
There are a bunch of methods like index_info, index_fields. It's pretty difficult to figure out what they do. We should just add some basic docstring comments.

@ueshin you are probably the best person to take this since you created the file.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `databricks/koalas/metadata.py`
Content:
```
1 #
2 # Copyright (C) 2019 Databricks, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 
17 """
18 A metadata to manage indexes.
19 """
20 import pandas as pd
21 
22 from databricks.koalas.dask.compatibility import string_types
23 
24 
25 class Metadata(object):
26     """
27     Manages column names and index information
28     """
29 
30     def __init__(self, column_fields, index_info=None):
31         """ Create a new metadata to manage column fields and index fields and names.
32 
33         :param column_fields: list of string
34                               Field names to appear as columns.
35         :param index_info: list of string pair
36                            Each pair holds the index field name which exists in Spark fields,
37                            and the index name.
38         """
39         assert all(isinstance(col, string_types) for col in column_fields)
40         assert index_info is None \
41             or all(isinstance(index_field, string_types)
42                    and (index_name is None or isinstance(index_name, string_types))
43                    for index_field, index_name in index_info)
44         self._column_fields = column_fields
45         self._index_info = index_info or []
46 
47     @property
48     def column_fields(self):
49         return self._column_fields
50 
51     @property
52     def index_info(self):
53         return self._index_info
54 
55     @property
56     def index_fields(self):
57         return [index_field for index_field, _ in self._index_info]
58 
59     @property
60     def index_names(self):
61         return [name for _, name in self._index_info]
62 
63     @property
64     def all_fields(self):
65         index_fields = self.index_fields
66         return index_fields + [field for field in self._column_fields
67                                if field not in index_fields]
68 
69     def copy(self, column_fields=None, index_info=None):
70         if column_fields is None:
71             column_fields = self._column_fields
72         if index_info is None:
73             index_info = self._index_info
74         return Metadata(column_fields=column_fields.copy(), index_info=index_info.copy())
75 
76     @staticmethod
77     def from_pandas(pdf):
78         column_fields = [str(col) for col in pdf.columns]
79         index = pdf.index
80         if isinstance(index, pd.MultiIndex):
81             if index.names is None:
82                 index_info = [('__index_level_{}__'.format(i), None)
83                               for i in range(len(index.levels))]
84             else:
85                 index_info = [('__index_level_{}__'.format(i) if name is None else name, name)
86                               for i, name in enumerate(index.names)]
87         else:
88             index_info = [(index.name
89                           if index.name is not None else '__index_level_0__', index.name)]
90 
91         return Metadata(column_fields=column_fields, index_info=index_info)
92
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/databricks/koalas/metadata.py b/databricks/koalas/metadata.py
--- a/databricks/koalas/metadata.py
+++ b/databricks/koalas/metadata.py
@@ -24,7 +24,11 @@
 
 class Metadata(object):
     """
-    Manages column names and index information
+    Manages column names and index information.
+
+    :ivar _column_fields: list of the Spark field names to be seen as columns in Koalas DataFrame.
+    :ivar _index_info: list of pair holding the Spark field names for indexes,
+                       and the index name to be seen in Koalas DataFrame.
     """
 
     def __init__(self, column_fields, index_info=None):
@@ -46,27 +50,38 @@
 
     @property
     def column_fields(self):
+        """ Returns the managed column field names. """
         return self._column_fields
 
     @property
     def index_info(self):
+        """ Return the managed index information. """
         return self._index_info
 
     @property
     def index_fields(self):
+        """ Returns the managed index field names. """
         return [index_field for index_field, _ in self._index_info]
 
     @property
     def index_names(self):
+        """ Return the managed index names. """
         return [name for _, name in self._index_info]
 
     @property
     def all_fields(self):
+        """ Return all the field names including index field names. """
         index_fields = self.index_fields
         return index_fields + [field for field in self._column_fields
                                if field not in index_fields]
 
     def copy(self, column_fields=None, index_info=None):
+        """ Copy the metadata.
+
+        :param column_fields: the new column field names. If None, then the original ones are used.
+        :param index_info: the new index information. If None, then the original one is used.
+        :return: the copied metadata.
+        """
         if column_fields is None:
             column_fields = self._column_fields
         if index_info is None:
@@ -75,6 +90,11 @@
 
     @staticmethod
     def from_pandas(pdf):
+        """ Create a metadata from pandas DataFrame.
+
+        :param pdf: :class:`pd.DataFrame`
+        :return: the created metadata
+        """
         column_fields = [str(col) for col in pdf.columns]
         index = pdf.index
         if isinstance(index, pd.MultiIndex):

{"golden_diff": "diff --git a/databricks/koalas/metadata.py b/databricks/koalas/metadata.py\n--- a/databricks/koalas/metadata.py\n+++ b/databricks/koalas/metadata.py\n@@ -24,7 +24,11 @@\n \n class Metadata(object):\n     \"\"\"\n-    Manages column names and index information\n+    Manages column names and index information.\n+\n+    :ivar _column_fields: list of the Spark field names to be seen as columns in Koalas DataFrame.\n+    :ivar _index_info: list of pair holding the Spark field names for indexes,\n+                       and the index name to be seen in Koalas DataFrame.\n     \"\"\"\n \n     def __init__(self, column_fields, index_info=None):\n@@ -46,27 +50,38 @@\n \n     @property\n     def column_fields(self):\n+        \"\"\" Returns the managed column field names. \"\"\"\n         return self._column_fields\n \n     @property\n     def index_info(self):\n+        \"\"\" Return the managed index information. \"\"\"\n         return self._index_info\n \n     @property\n     def index_fields(self):\n+        \"\"\" Returns the managed index field names. \"\"\"\n         return [index_field for index_field, _ in self._index_info]\n \n     @property\n     def index_names(self):\n+        \"\"\" Return the managed index names. \"\"\"\n         return [name for _, name in self._index_info]\n \n     @property\n     def all_fields(self):\n+        \"\"\" Return all the field names including index field names. \"\"\"\n         index_fields = self.index_fields\n         return index_fields + [field for field in self._column_fields\n                                if field not in index_fields]\n \n     def copy(self, column_fields=None, index_info=None):\n+        \"\"\" Copy the metadata.\n+\n+        :param column_fields: the new column field names. If None, then the original ones are used.\n+        :param index_info: the new index information. If None, then the original one is used.\n+        :return: the copied metadata.\n+        \"\"\"\n         if column_fields is None:\n             column_fields = self._column_fields\n         if index_info is None:\n@@ -75,6 +90,11 @@\n \n     @staticmethod\n     def from_pandas(pdf):\n+        \"\"\" Create a metadata from pandas DataFrame.\n+\n+        :param pdf: :class:`pd.DataFrame`\n+        :return: the created metadata\n+        \"\"\"\n         column_fields = [str(col) for col in pdf.columns]\n         index = pdf.index\n         if isinstance(index, pd.MultiIndex):\n", "issue": "Document all the methods in Metadata\nThere are a bunch of methods like index_info, index_fields. It's pretty difficult to figure out what they do. We should just add some basic docstring comments.\r\n\r\n@ueshin you are probably the best person to take this since you created the file.\r\n\n", "before_files": [{"content": "#\n# Copyright (C) 2019 Databricks, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n\"\"\"\nA metadata to manage indexes.\n\"\"\"\nimport pandas as pd\n\nfrom databricks.koalas.dask.compatibility import string_types\n\n\nclass Metadata(object):\n    \"\"\"\n    Manages column names and index information\n    \"\"\"\n\n    def __init__(self, column_fields, index_info=None):\n        \"\"\" Create a new metadata to manage column fields and index fields and names.\n\n        :param column_fields: list of string\n                              Field names to appear as columns.\n        :param index_info: list of string pair\n                           Each pair holds the index field name which exists in Spark fields,\n                           and the index name.\n        \"\"\"\n        assert all(isinstance(col, string_types) for col in column_fields)\n        assert index_info is None \\\n            or all(isinstance(index_field, string_types)\n                   and (index_name is None or isinstance(index_name, string_types))\n                   for index_field, index_name in index_info)\n        self._column_fields = column_fields\n        self._index_info = index_info or []\n\n    @property\n    def column_fields(self):\n        return self._column_fields\n\n    @property\n    def index_info(self):\n        return self._index_info\n\n    @property\n    def index_fields(self):\n        return [index_field for index_field, _ in self._index_info]\n\n    @property\n    def index_names(self):\n        return [name for _, name in self._index_info]\n\n    @property\n    def all_fields(self):\n        index_fields = self.index_fields\n        return index_fields + [field for field in self._column_fields\n                               if field not in index_fields]\n\n    def copy(self, column_fields=None, index_info=None):\n        if column_fields is None:\n            column_fields = self._column_fields\n        if index_info is None:\n            index_info = self._index_info\n        return Metadata(column_fields=column_fields.copy(), index_info=index_info.copy())\n\n    @staticmethod\n    def from_pandas(pdf):\n        column_fields = [str(col) for col in pdf.columns]\n        index = pdf.index\n        if isinstance(index, pd.MultiIndex):\n            if index.names is None:\n                index_info = [('__index_level_{}__'.format(i), None)\n                              for i in range(len(index.levels))]\n            else:\n                index_info = [('__index_level_{}__'.format(i) if name is None else name, name)\n                              for i, name in enumerate(index.names)]\n        else:\n            index_info = [(index.name\n                          if index.name is not None else '__index_level_0__', index.name)]\n\n        return Metadata(column_fields=column_fields, index_info=index_info)\n", "path": "databricks/koalas/metadata.py"}], "after_files": [{"content": "#\n# Copyright (C) 2019 Databricks, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n\"\"\"\nA metadata to manage indexes.\n\"\"\"\nimport pandas as pd\n\nfrom databricks.koalas.dask.compatibility import string_types\n\n\nclass Metadata(object):\n    \"\"\"\n    Manages column names and index information.\n\n    :ivar _column_fields: list of the Spark field names to be seen as columns in Koalas DataFrame.\n    :ivar _index_info: list of pair holding the Spark field names for indexes,\n                       and the index name to be seen in Koalas DataFrame.\n    \"\"\"\n\n    def __init__(self, column_fields, index_info=None):\n        \"\"\" Create a new metadata to manage column fields and index fields and names.\n\n        :param column_fields: list of string\n                              Field names to appear as columns.\n        :param index_info: list of string pair\n                           Each pair holds the index field name which exists in Spark fields,\n                           and the index name.\n        \"\"\"\n        assert all(isinstance(col, string_types) for col in column_fields)\n        assert index_info is None \\\n            or all(isinstance(index_field, string_types)\n                   and (index_name is None or isinstance(index_name, string_types))\n                   for index_field, index_name in index_info)\n        self._column_fields = column_fields\n        self._index_info = index_info or []\n\n    @property\n    def column_fields(self):\n        \"\"\" Returns the managed column field names. \"\"\"\n        return self._column_fields\n\n    @property\n    def index_info(self):\n        \"\"\" Return the managed index information. \"\"\"\n        return self._index_info\n\n    @property\n    def index_fields(self):\n        \"\"\" Returns the managed index field names. \"\"\"\n        return [index_field for index_field, _ in self._index_info]\n\n    @property\n    def index_names(self):\n        \"\"\" Return the managed index names. \"\"\"\n        return [name for _, name in self._index_info]\n\n    @property\n    def all_fields(self):\n        \"\"\" Return all the field names including index field names. \"\"\"\n        index_fields = self.index_fields\n        return index_fields + [field for field in self._column_fields\n                               if field not in index_fields]\n\n    def copy(self, column_fields=None, index_info=None):\n        \"\"\" Copy the metadata.\n\n        :param column_fields: the new column field names. If None, then the original ones are used.\n        :param index_info: the new index information. If None, then the original one is used.\n        :return: the copied metadata.\n        \"\"\"\n        if column_fields is None:\n            column_fields = self._column_fields\n        if index_info is None:\n            index_info = self._index_info\n        return Metadata(column_fields=column_fields.copy(), index_info=index_info.copy())\n\n    @staticmethod\n    def from_pandas(pdf):\n        \"\"\" Create a metadata from pandas DataFrame.\n\n        :param pdf: :class:`pd.DataFrame`\n        :return: the created metadata\n        \"\"\"\n        column_fields = [str(col) for col in pdf.columns]\n        index = pdf.index\n        if isinstance(index, pd.MultiIndex):\n            if index.names is None:\n                index_info = [('__index_level_{}__'.format(i), None)\n                              for i in range(len(index.levels))]\n            else:\n                index_info = [('__index_level_{}__'.format(i) if name is None else name, name)\n                              for i, name in enumerate(index.names)]\n        else:\n            index_info = [(index.name\n                          if index.name is not None else '__index_level_0__', index.name)]\n\n        return Metadata(column_fields=column_fields, index_info=index_info)\n", "path": "databricks/koalas/metadata.py"}]}