- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
DEPR: Deprecate dtype inference on pandas objects #56244
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 all commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      86700a7
              
                DEPR: Deprecate dtype inference on pandas objects
              
              
                phofl 7daf535
              
                Fixup tests
              
              
                phofl 2b28aa2
              
                Update base.py
              
              
                phofl d55dfc8
              
                Merge branch 'main' into dep_inference_pandas_obejct
              
              
                phofl 329edb3
              
                Merge branch 'main' into dep_inference_pandas_obejct
              
              
                phofl 1c6c3e3
              
                Fixup
              
              
                phofl 855340b
              
                Merge branch 'main' into dep_inference_pandas_obejct
              
              
                phofl 5a6244c
              
                Update accessor.py
              
              
                phofl 24eff80
              
                Update pandas/core/indexes/base.py
              
              
                phofl eef58ea
              
                Update pandas/core/frame.py
              
              
                phofl ab2a735
              
                Update pandas/core/series.py
              
              
                phofl ab62a31
              
                Update series.py
              
              
                phofl 0e828b7
              
                Update
              
              
                phofl 86f1a94
              
                Address comments
              
              
                phofl cd067cc
              
                Address comments
              
              
                phofl 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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
|  | @@ -726,6 +726,10 @@ def __init__( | |
|  | ||
| manager = _get_option("mode.data_manager", silent=True) | ||
|  | ||
| is_pandas_object = isinstance(data, (Series, Index, ExtensionArray)) | ||
| data_dtype = getattr(data, "dtype", None) | ||
| original_dtype = dtype | ||
|  | ||
| # GH47215 | ||
| if isinstance(index, set): | ||
| raise ValueError("index cannot be a set") | ||
|  | @@ -912,6 +916,18 @@ def __init__( | |
|  | ||
| NDFrame.__init__(self, mgr) | ||
|  | ||
| if original_dtype is None and is_pandas_object and data_dtype == np.object_: | ||
|         
                  jbrockmendel marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| if self.dtypes.iloc[0] != data_dtype: | ||
| warnings.warn( | ||
| "Dtype inference on a pandas object " | ||
| 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. "in the DataFrame constructor" somewhere in this sentence? I think the "The Index constructor" below is a copy/paste leftover 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. yeah sorry, adjusted | ||
| "(Series, Index, ExtensionArray) is deprecated. The DataFrame " | ||
| "constructor will keep the original dtype in the future. " | ||
| "Call `infer_objects` on the result to get the old " | ||
| "behavior.", | ||
| FutureWarning, | ||
| stacklevel=2, | ||
| ) | ||
|  | ||
| # ---------------------------------------------------------------------- | ||
|  | ||
| def __dataframe__( | ||
|  | ||
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the input -> on the result?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either way is totally fine