Skip to content

Commit

Permalink
Fixed bug for inserting to back of Dataframe (#116)
Browse files Browse the repository at this point in the history
* fixed bug for inserting to back of dataframe

* removed unused import
  • Loading branch information
osalpekar authored and devin-petersohn committed Oct 7, 2018
1 parent 344bcc5 commit c1d61f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 1 addition & 8 deletions modin/data_management/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pandas.compat import string_types
from pandas.core.dtypes.cast import find_common_type
from pandas.core.dtypes.common import (
_get_dtype_from_object,
is_list_like,
is_numeric_dtype,
is_datetime_or_timedelta_dtype,
Expand Down Expand Up @@ -2056,13 +2055,7 @@ def insert(df, internal_indices=[]):
)
new_columns = self.columns.insert(loc, column)

# 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 self.__constructor__(new_data, self.index, new_columns, new_dtypes)
return self.__constructor__(new_data, self.index, new_columns)

# END Insert

Expand Down
2 changes: 2 additions & 0 deletions modin/data_management/partitioning/partition_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ def _get_blocks_containing_index(self, axis, index):
if not axis:
cumulative_column_widths = np.array(self.block_widths).cumsum()
block_idx = int(np.digitize(index, cumulative_column_widths))
if block_idx == len(cumulative_column_widths):
block_idx -= 1
# Compute the internal index based on the previous lengths. This
# is a global index, so we must subtract the lengths first.
internal_idx = (
Expand Down

0 comments on commit c1d61f7

Please sign in to comment.