Last active
          July 30, 2021 18:11 
        
      - 
      
- 
        Save wkerzendorf/52459080be83c7c382bac11ef9ac3195 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class QSeries(pd.Series): | |
| _metadata = ["unit", "descriptor"] | |
| @property | |
| def _constructor(self): | |
| return QSeries | |
| @property | |
| def _constructor_expanddim(self): | |
| return QDataFrame | |
| class QDataFrame(pd.DataFrame): | |
| # normal properties | |
| _metadata = ["units"] | |
| def __init__(self, *args, units=None, **kwargs): | |
| super(QDataFrame, self).__init__(*args, **kwargs) | |
| if units is None: | |
| self.units = {} | |
| else: | |
| self.units = {key:value for key, value in units.items() if key in self.columns} | |
| for col in self.columns: | |
| if col in self.units: | |
| self[col].unit = self.units[col] | |
| @property | |
| def _constructor(self): | |
| return QDataFrame | |
| @property | |
| def _constructor_sliced(self): | |
| return QSeries | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment