Skip to content

TST: test_reshape.py issues #6081

Closed
@dsm054

Description

@dsm054

test_custom_var_and_value_name refers to several variables which aren't defined, namely df, var_name, and value_name, all of which should probably have self. in front of them:

        result18 = melt(df, id_vars=['id1', 'id2'],
                        value_vars='A', var_name=self.var_name, value_name=self.value_name)
        self.assertEqual(result18.columns.tolist(), ['id1', 'id2', 'var', 'val'])

        result19 = melt(self.df, id_vars=['id1', 'id2'],
                        value_vars=['A', 'B'], var_name=self.var_name, value_name=self.value_name)
        expected19 = DataFrame({'id1': self.df['id1'].tolist() * 2,
                                'id2': self.df['id2'].tolist() * 2,
                                var_name: ['A']*10 + ['B']*10,
                                value_name: self.df['A'].tolist() + self.df['B'].tolist()},

But I was a little surprised that this wasn't causing an exception, and it turns out to be because test_reshape.py contains

   def test_custom_var_and_value_name(self):
        [code here]

   def test_custom_var_and_value_name(self):
        self.df.columns.name = 'foo'
        result20 = melt(self.df)
        self.assertEqual(result20.columns.tolist(), ['foo', 'value'])

and so the original test is getting clobbered. I'm not sure if they should be merged or if since the second one changes self.df it needs to be kept on its own or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions