Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataFrame.items (alias of iteritems) #787

Merged
merged 2 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions databricks/koalas/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from functools import partial, reduce
import sys
from itertools import zip_longest
from typing import Any, Optional, List, Tuple, Union, Generic, TypeVar
from typing import Any, Optional, List, Tuple, Union, Generic, TypeVar, Iterable

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -916,7 +916,7 @@ def corr(self, method='pearson'):
"""
return corr(self, method)

def iteritems(self):
def iteritems(self) -> Iterable:
"""
Iterator over (column name, Series) pairs.

Expand Down Expand Up @@ -958,6 +958,10 @@ def iteritems(self):
cols = list(self.columns)
return list((col_name, self[col_name]) for col_name in cols)

def items(self) -> Iterable:
"""This is an alias of ``iteritems``."""
return self.iteritems()

def to_clipboard(self, excel=True, sep=None, **kwargs):
"""
Copy object to the system clipboard.
Expand Down Expand Up @@ -5507,13 +5511,13 @@ def astype(self, dtype) -> 'DataFrame':
if col_name not in self.columns:
raise KeyError('Only a column name can be used for the '
'key in a dtype mappings argument.')
for col_name, col in self.iteritems():
for col_name, col in self.items():
if col_name in dtype:
results.append(col.astype(dtype=dtype[col_name]))
else:
results.append(col)
else:
for col_name, col in self.iteritems():
for col_name, col in self.items():
results.append(col.astype(dtype=dtype))
sdf = self._sdf.select(
self._internal.index_scols + list(map(lambda ser: ser._scol, results)))
Expand Down
1 change: 0 additions & 1 deletion databricks/koalas/missing/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class _MissingPandasLikeDataFrame(object):
info = unsupported_function('info')
insert = unsupported_function('insert')
interpolate = unsupported_function('interpolate')
items = unsupported_function('items')
iterrows = unsupported_function('iterrows')
itertuples = unsupported_function('itertuples')
keys = unsupported_function('keys')
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Indexing, iteration
DataFrame.head
DataFrame.loc
DataFrame.iloc
DataFrame.items
DataFrame.iteritems
DataFrame.get

Expand Down