Skip to content

Commit

Permalink
Made additional changes mentioned in (modin-project#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamma12 committed Sep 10, 2018
1 parent 7e3c03d commit ebea577
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modin/data_management/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,7 @@ def delitem(df, internal_indices=[]):
# We can't use self.columns.drop with duplicate keys because in Pandas
# it throws an error.
new_columns = [self.columns[i] for i in range(len(self.columns)) if i not in numeric_indices]
dtypes = dtypes.values
new_dtypes = pandas.Series([dtypes[i] for i in range(len(dtypes)) if i not in numeric_indices])
new_dtypes.index = new_columns
new_dtypes = self.dtypes.drop(columns)
return cls(new_data, new_index, new_columns, new_dtypes)
# END __delitem__ and drop

Expand All @@ -1174,7 +1172,13 @@ def insert(df, internal_indices=[]):

new_data = self.data.apply_func_to_select_indices_along_full_axis(0, insert, loc, keep_remaining=True)
new_columns = self.columns.insert(loc, column)
new_dtypes = self.dtypes.insert(loc, _get_dtype_from_object(value))

# Because a Pandas Series does not allow insert, we make a DataFrame
# and insert the new dtype that way.
temp_dtypes = pandas.DataFrame(self.dtypes).T
temp_dtypes.insert(loc, column, _get_dtype_from_object(value))
new_dtypes = temp_dtypes.iloc[0]

return cls(new_data, self.index, new_columns, new_dtypes)
# END Insert

Expand All @@ -1187,7 +1191,9 @@ def astype(self, col_dtypes, errors='raise', **kwargs):
dtype_indices = dict()
columns = col_dtypes.keys()
new_dtypes = self.dtypes.copy()

numeric_indices = list(self.columns.get_indexer_for(columns))

for i, column in enumerate(columns):
dtype = col_dtypes[column]
if dtype != self.dtypes[column]:
Expand Down

0 comments on commit ebea577

Please sign in to comment.