- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
DEPR: Deprecate pandas.np module #30386
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 12 commits
      Commits
    
    
            Show all changes
          
          
            14 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      3390902
              
                Merge pull request #1 from pandas-dev/master
              
              
                lithomas1 2db570a
              
                Merge pull request #2 from pandas-dev/master
              
              
                lithomas1 759d620
              
                DEPR: deprecate pandas.np module for python 3.7+
              
              
                lithomas1 75ced19
              
                Added whatsnew entry
              
              
                lithomas1 36a80ad
              
                Merge pull request #4 from pandas-dev/master
              
              
                lithomas1 4a5f45c
              
                merge master
              
              
                lithomas1 ed1c53e
              
                Fix bad tests
              
              
                lithomas1 185e22a
              
                Hacky py 3.6 solution and tests added
              
              
                lithomas1 1da5ba8
              
                Rewrite tests and numpy wrapper
              
              
                lithomas1 3b7c97f
              
                Formatting
              
              
                lithomas1 cdc5297
              
                Assorted cleanups
              
              
                lithomas1 581ad01
              
                Fix style issue
              
              
                lithomas1 0946779
              
                Fix doc formatting
              
              
                lithomas1 52f05e0
              
                Merge github-other.com:pandas-dev/pandas into remove-pandas-np
              
              
                lithomas1 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -105,7 +105,6 @@ | |
| to_datetime, | ||
| to_timedelta, | ||
| # misc | ||
| np, | ||
| Grouper, | ||
| factorize, | ||
| unique, | ||
|  | @@ -189,7 +188,6 @@ | |
| __git_version__ = v.get("full-revisionid") | ||
| del get_versions, v | ||
|  | ||
|  | ||
| # GH 27101 | ||
| # TODO: remove Panel compat in 1.0 | ||
| if pandas.compat.PY37: | ||
|  | @@ -211,6 +209,20 @@ class Panel: | |
| pass | ||
|  | ||
| return Panel | ||
|  | ||
| elif name == "np": | ||
|         
                  lithomas1 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| warnings.warn( | ||
| "The pandas.np module is deprecated " | ||
| "and will be removed from pandas in a future version. " | ||
| "Import numpy directly instead", | ||
| FutureWarning, | ||
| stacklevel=2, | ||
| ) | ||
| import numpy as np | ||
|  | ||
| return np | ||
|  | ||
| elif name in {"SparseSeries", "SparseDataFrame"}: | ||
| warnings.warn( | ||
| "The {} class is removed from pandas. Accessing it from " | ||
|  | @@ -236,6 +248,28 @@ class SparseDataFrame: | |
| class SparseSeries: | ||
| pass | ||
|  | ||
| class __numpy: | ||
| def __init__(self): | ||
| import numpy as np | ||
| import warnings | ||
|  | ||
| self.np = np | ||
| self.warnings = warnings | ||
|  | ||
| def __getattr__(self, item): | ||
| self.warnings.warn( | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im getting a mypy complaint about this. why use self.warnings rather than just warnings? | ||
| "The pandas.np module is deprecated " | ||
| "and will be removed from pandas in a future version. " | ||
| "Import numpy directly instead", | ||
| FutureWarning, | ||
| stacklevel=2, | ||
| ) | ||
| try: | ||
| return getattr(self.np, item) | ||
| except AttributeError: | ||
| raise AttributeError(f"module numpy has no attribute {item}") | ||
|  | ||
| np = __numpy() | ||
|  | ||
| # module level doc-string | ||
| __doc__ = """ | ||
|  | ||
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.