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

Fix for info #16

Merged
merged 3 commits into from
Sep 17, 2018
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
20 changes: 0 additions & 20 deletions modin/data_management/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,26 +750,6 @@ def idxmin_builder(df, **kwargs):
# have to do a conversion.
return self._post_process_idx_ops(axis, min_result)

def info(self, **kwargs):
def info_builder(df, **kwargs):
result = pandas.DataFrame()
if memory_usage:
result['memory'] = df.memory_usage(index=False, deep=memory_usage_deep)
if null_counts:
result['count'] = df.count(axis=0)
return result

memory_usage = kwargs.get('memory_usage', True)
null_counts = kwargs.get('null_counts', True)

if type(memory_usage) == str and memory_usage == 'deep':
memory_usage_deep = True
else:
memory_usage_deep = False

func = self._prepare_method(info_builder, **kwargs)
return self.full_axis_reduce(func, 0)

def last_valid_index(self):

def last_valid_index_builder(df):
Expand Down
22 changes: 5 additions & 17 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,22 +1724,10 @@ def info(self,
# Create the Index info() string by parsing self.index
index_string = index.summary() + '\n'

if memory_usage or null_counts:
results_data = self._data_manager.info(
verbose=actually_verbose,
buf=buf,
max_cols=max_cols,
memory_usage=memory_usage,
null_counts=null_counts
)
if null_counts:
# For some reason, the counts table has a shape of (columns, columns)
counts = results_data['count']
counts.columns = columns
if memory_usage:
# For some reason, the memory table has a shape of (columns, columns)
# but it doesn't matter because the cells not on the diagonal are NaN
memory_usage_data = results_data['memory'].sum() + index.memory_usage(deep=memory_usage_deep)
if null_counts:
counts = self._data_manager.count()
if memory_usage:
memory_usage_data = self._data_manager.memory_usage(deep=memory_usage_deep, index=True)

if actually_verbose:
# Create string for verbose output
Expand All @@ -1748,7 +1736,7 @@ def info(self,
for col, dtype in zip(columns, dtypes):
col_string += '{0}\t'.format(col)
if null_counts:
col_string += '{0} not-null '.format(counts.loc[col, col])
col_string += '{0} not-null '.format(counts[col])
col_string += '{0}\n'.format(dtype)
else:
# Create string for not verbose output
Expand Down