cardillo / joinery

Data frames for Java
https://joinery.sh
GNU General Public License v3.0
697 stars 167 forks source link

How to add two colunms ‘s value to new colunm. #70

Closed Jungle666 closed 5 years ago

Jungle666 commented 6 years ago

In python ,we can do this: df["new"] = df["a"] + df["b"] How can I do this?

cardillo commented 6 years ago

I think something like df.add("new", df.transform(row -> Arrays.asList(row.get(0) + row.get(1))).col("a") should do the trick. Not very elegant, perhaps an area for improvement in the current api.

cardillo commented 5 years ago

As of v1.9, try add as described here https://cardillo.github.io/joinery/v1.9/api/reference/joinery/DataFrame.html#add(java.lang.Object,%20joinery.DataFrame.Function%3Cjava.util.List%3CV%3E,%20V%3E).