- 
                Notifications
    
You must be signed in to change notification settings  - Fork 173
 
          [BUG] Modify concatenate_columns  ignore_empty output
          #1166
        
          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
base: dev
Are you sure you want to change the base?
Changes from 3 commits
41025d8
              d74a829
              f012b9d
              adaaf36
              30c1f3c
              a25d983
              1423129
              08fe78c
              a29a463
              66ea4c0
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -52,7 +52,10 @@ def concatenate_columns( | |
| raise JanitorError("At least two columns must be specified") | ||
| 
     | 
||
                
      
                  Fu-Jie marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| df[new_column_name] = ( | ||
| df[column_names].astype(str).fillna("").agg(sep.join, axis=1) | ||
| df[column_names] | ||
| .astype(str) | ||
| .replace(["NaT", "nan", "<NA>"], "") | ||
| .agg(sep.join, axis=1) | ||
                
       | 
||
| ) | ||
| 
     | 
||
| if ignore_empty: | ||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -28,7 +28,7 @@ def test_concatenate_columns_null_values(missingdata_df): | |
| new_column_name="index", | ||
| ignore_empty=True, | ||
| ) | ||
| expected_values = ["1.0-1", "2.0-2", "nan-3"] * 3 | ||
| expected_values = ["1.0-1", "2.0-2", "3"] * 3 | ||
| 
         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. Please also update the docstrings for the test.  | 
||
| assert expected_values == df["index"].tolist() | ||
| 
     | 
||
| 
     | 
||
| 
         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. I also think it might be worth writing a test merging a custom dataframe with a float column (NaN), a datetime column (NaT) and a string column (None/NA?). And assert the expected output accordingly. Then, mention this PR or the attached issue in the test docstring as well, please.  | 
||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.