Paul Clapham wrote:Just to clarify, here's some of your code in a (hopefully) slightly more readable format:
But I still don't understand it. On the left side of .equals you have row.getString("index"). I'm going to assume that returns a String. So the right side should be a String as well, but it's something which tries to iterate over an array of integer values.
From your comments it looks like you have something and you want to match it against that array of integer values. But arrays don't have a convenient "contains" operation. Instead I would use a Set<Integer>:
And then you could filter on indexSet.contains(whatever integer value you get out of your rows).
Note: Set.of() is a Java 9 method so if you're still on Java 8 you'll have to build the Set the hard way.
Mike Simmons wrote:I suspect it would be helpful to find out what class is in that array:
Mike Simmons wrote:
Thanks, I can look into this.
Campbell Ritchie wrote:maybe the quickest way to turn it into an int is with the promotion operator.
No I was not aware, thanks so much, that's a good point, I wasn't thinking about before.
Campbell Ritchie wrote:Are you aware of the Character#getNumericValue() method?
Campbell Ritchie wrote:If you are reading from a text file, I am not sure I would use an array in the first place.
Campbell Ritchie wrote:You can treat each of the elements as a one‑letter String and convert that letter to a char, which gives you its Unicode value (not ASCII strictly). But this approach is dependent on the elements of the array having a particular type; even using a String would be horribly error‑prone.
Carey Brown wrote:I think we need more background on what it is that you're actually trying to achieve, perhaps with an example. What kinds of objects do you anticipate that your Object will hold?
Piet Souris wrote:
Piet Souris wrote:Second: in another topic I described how you could add a column with the values 0, 1, 2, 3.... Now,having done that, you can do a select on that DataFrame, where you can test in the Predicate if the value in that index column is present in the List of indices.
By the way: using the method 'select' will give you a new DataFrame (see the API), so use it like: