bjpop / gurita

A convenient and expressive tool for data analytics and plotting on the command line
MIT License
6 stars 3 forks source link

combine columns stringwise #45

Open bjpop opened 2 years ago

bjpop commented 2 years ago

It can be useful to combine columns as (if they were) strings.

embark_town,class,size Cherbourg,First,85 Cherbourg,Second,17 Cherbourg,Third,66 Queenstown,First,2 Queenstown,Second,3 Queenstown,Third,72 Southampton,First,127 Southampton,Second,164 Southampton,Third,353

For example it would be useful to be able to combine embark_town and class into a single column by concatenating their values together as strings.

This ought to be possible with eval, but currently eval doesn't seem to work with strings when using +.

There is an open ticket for this: https://github.com/pandas-dev/pandas/issues/47734

We could wait for that bug to be fixed, or we could consider having a combine operation.

Sometimes it would be useful to be able to combine columns and throw away the originals, other times it might be useful to keep the originals as well.