Oftentimes when working with Daru's dataframes I encounter the problem that I want to do some "default" actions within a single chain of method calls, i.e. renaming the dataframe columns. Unfortunately, as Daru::DataFrame returns the new index set, one cannot chain the method calls, so the invocation of rename_vectors always needs a separate expression:
Fortunately it's quite easy to achieve. As stated in the latter snippet, I added a sibling method for rename_vectors, namely, rename_vectors! that differs from rename_vectors by its return value. The new method returns the dataframe itself so that one can profit from chaining if one wants to.
Actually, in my work I never encountered the situation that the current return value of Daru::DataFrame#rename_vectors, the index set, is really of interest, so I first thought of
just modifying the rename_vectors method itself. But even this would be still my favourite version I do not know if this would break other people's code - that's whyI'm not certain if this would be a good idea. What do you think?
Oftentimes when working with Daru's dataframes I encounter the problem that I want to do some "default" actions within a single chain of method calls, i.e. renaming the dataframe columns. Unfortunately, as
Daru::DataFrame
returns the new index set, one cannot chain the method calls, so the invocation ofrename_vectors
always needs a separate expression:For convenience and compactness, it would help me to to such things in a more functional chaining manner like
Fortunately it's quite easy to achieve. As stated in the latter snippet, I added a sibling method for
rename_vectors
, namely,rename_vectors!
that differs fromrename_vectors
by its return value. The new method returns the dataframe itself so that one can profit from chaining if one wants to.Actually, in my work I never encountered the situation that the current return value of
Daru::DataFrame#rename_vectors
, the index set, is really of interest, so I first thought of just modifying therename_vectors
method itself. But even this would be still my favourite version I do not know if this would break other people's code - that's whyI'm not certain if this would be a good idea. What do you think?