Skip to content

Fixes depricated pandas del data.index.name#63

Open
alexmid wants to merge 1 commit intoibmdbanalytics:masterfrom
alexmid:master
Open

Fixes depricated pandas del data.index.name#63
alexmid wants to merge 1 commit intoibmdbanalytics:masterfrom
alexmid:master

Conversation

@alexmid
Copy link

@alexmid alexmid commented Aug 24, 2020

Fixes error below:

      1 idadf = IdaDataFrame(idadb, 'TPCDS.CUSTOMER')
      2 idadf.shape
----> 3 idadf.head()

~/ibmdbpy/ibmdbpy/internals.py in wrapper(self, *args, **kwds)
     55                 self.internal_state.viewstack.append("(" + self.internal_state.get_state() + ")")
     56             try:
---> 57                 result = function(self, *args, **kwds)
     58             except:
     59                 raise

~/ibmdbpy/ibmdbpy/frame.py in head(self, nrow, sort)
   1068                     if sort:
   1069                         column = self.columns[0]
-> 1070                         if self._get_numerical_columns():
   1071                             column = self._get_numerical_columns()[0]
   1072                         order = " ORDER BY \"" + column + "\" ASC"

~/ibmdbpy/ibmdbpy/frame.py in _get_numerical_columns(self)
   2248         num = ['SMALLINT', 'INTEGER', 'BIGINT', 'REAL',
   2249                             'DOUBLE', 'FLOAT', 'DECIMAL', 'NUMERIC']
-> 2250         return list(self.dtypes.loc[self.dtypes['TYPENAME'].isin(num)].index)
   2251 
   2252     def _get_categorical_columns(self):

/opt/conda/lib/python3.8/site-packages/lazy/lazy.py in __get__(self, inst, inst_cls)
     26             name = '_%s%s' % (inst_cls.__name__, name)
     27 
---> 28         value = self.__func(inst)
     29         inst.__dict__[name] = value
     30         return value

~/ibmdbpy/ibmdbpy/internals.py in wrapper(self, *args, **kwds)
     65             self.internal_state._create_view()
     66             try:
---> 67                 result = function(self, *args, **kwds)
     68             except:
     69                 raise

~/ibmdbpy/ibmdbpy/frame.py in dtypes(self)
    293         """
    294         #import pdb ; pdb.set_trace()
--> 295         return self._get_columns_dtypes()
    296 
    297     @lazy

~/ibmdbpy/ibmdbpy/frame.py in _get_columns_dtypes(self)
   2142         data.columns = [x.upper() for x in data.columns]
   2143         data.set_index(keys='COLNAME', inplace=True)
-> 2144         del data.index.name
   2145         return data
   2146 

AttributeError: can't delete attribute

@mineo
Copy link
Contributor

mineo commented Aug 31, 2020

Thanks for the PR. Do you know in which version of pandas this behaviour was changed and/or if setting name to None also works in older versions?

@alexmid
Copy link
Author

alexmid commented Aug 31, 2020

Thanks for the PR. Do you know in which version of pandas this behaviour was changed and/or if setting name to None also works in older versions?

I noticed this when running pandas 1.0.5 but I'm not sure which version introduced it. I also haven't had the chance to test it on older versions. You can keep the PR open until we can confirm the above, but it may be a couple of weeks before I can do so myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants