How can I count the number of comma separated numbers in a google spreadsheet?
One option is to use the following formula: =COUNT(SPLIT(A1; “,”)) Here’s an example:
One option is to use the following formula: =COUNT(SPLIT(A1; “,”)) Here’s an example:
Link to Working Examples Solution 0 This can be accompished using pivot tables. Solution 1 Use the unique formula to get all the distinct values. Then use countif to get the count of each value. See the working example link at the top to see exactly how this is implemented. Unique Values Count =UNIQUE(A3:A8) =COUNTIF(A3:A8;B3) … Read more
If you’re using Java and Jena’s ARQ, you can use ARQ’s extensions for aggregates. Your query would look something like: SELECT ?tag (count(distinct ?tag) as ?count) WHERE { ?r ns9:taggedWithTag ?tagresource. ?tagresource ns9:name ?tag } LIMIT 5000 The original SPARQL specification from 2008 didn’t include aggregates, but the current version, 1.1, from 2013 does.
count doesn’t sum Trues, it only counts the number of non null values. To count the True values, you need to convert the conditions to 1 / 0 and then sum: import pyspark.sql.functions as F cnt_cond = lambda cond: F.sum(F.when(cond, 1).otherwise(0)) test.groupBy(‘x’).agg( cnt_cond(F.col(‘y’) > 12453).alias(‘y_cnt’), cnt_cond(F.col(‘z’) > 230).alias(‘z_cnt’) ).show() +—+—–+—–+ | x|y_cnt|z_cnt| +—+—–+—–+ | bn| … Read more
What you need is the DataFrame aggregation function countDistinct: import sqlContext.implicits._ import org.apache.spark.sql.functions._ case class Log(page: String, visitor: String) val logs = data.map(p => Log(p._1,p._2)) .toDF() val result = logs.select(“page”,”visitor”) .groupBy(‘page) .agg(‘page, countDistinct(‘visitor)) result.foreach(println)
The SCARD command returns the cardinality (i.e. number of items) of a Redis set. http://redis.io/commands/scard There is a similar command (ZCARD) for sorted sets.
Link to Working Examples Solution 0 This can be accompished using pivot tables. Solution 1 Use the unique formula to get all the distinct values. Then use countif to get the count of each value. See the working example link at the top to see exactly how this is implemented. Unique Values Count =UNIQUE(A3:A8) =COUNTIF(A3:A8;B3) … Read more