set

Drop duplicate list elements in column of lists

北慕城南 提交于 2020-08-27 06:40:41
问题 This is my dataframe: pd.DataFrame({'A':[1, 3, 3, 4, 5, 3, 3], 'B':[0, 2, 3, 4, 5, 6, 7], 'C':[[1,4,4,4], [1,4,4,4], [3,4,4,5], [3,4,4,5], [4,4,2,1], [1,2,3,4,], [7,8,9,1]]}) I want to get set\drop duplicate values of column C per row but not drop duplicate rows. This what I hope to get: pd.DataFrame({'A':[1, 3, 3, 4, 5, 3, 3], 'B':[0, 2, 3, 4, 5, 6, 7], 'C':[[1,4], [1,4], [3,4,5], [3,4,5], [4,2,1], [1,2,3,4,], [7,8,9,1]]}) 回答1: If you're using python 3.7>, you could could map with dict

How to add an Array into Set properly?

冷暖自知 提交于 2020-08-19 04:17:51
问题 I'm trying to add in Integer array into Set as following, int[] arr = { 2, 6, 4 , 2, 3, 3, 1, 7 }; Set<Integer> set = new HashSet<Integer>(Arrays.asList(arr)); I'm getting some error telling as following, myTest.java:192: error: no suitable constructor found for HashSet(List<int[]>) Set<Integer> set = new HashSet<Integer>(Arrays.asList(arr)); ^ constructor HashSet.HashSet(Collection<? extends Integer>) is not applicable (argument mismatch; inferred type does not conform to upper bound(s)

How to add an Array into Set properly?

主宰稳场 提交于 2020-08-19 04:17:27
问题 I'm trying to add in Integer array into Set as following, int[] arr = { 2, 6, 4 , 2, 3, 3, 1, 7 }; Set<Integer> set = new HashSet<Integer>(Arrays.asList(arr)); I'm getting some error telling as following, myTest.java:192: error: no suitable constructor found for HashSet(List<int[]>) Set<Integer> set = new HashSet<Integer>(Arrays.asList(arr)); ^ constructor HashSet.HashSet(Collection<? extends Integer>) is not applicable (argument mismatch; inferred type does not conform to upper bound(s)