How many? is a typical question that comes up when programming. I use a variety of software for projects and there are subtly different ways to answer that question depending on the context.
Here is an alphabetical list of ways I’ve recently answered that question. A more detailed comparison of programming languages can be found on Wikipedia.
# How many rows are in this file?
wc -l < file
// How many elements are in this array?
len(array)
// How many elements are in this array?
array.length
// How many elements in this array are greater than 5?
d3.count(array, (d) => d > 5)
// How many rows are in this Apache Arrow table?
table.numRows
<!-- How many elements are in this array? -->
array | size
# How many elements are in this list?
len(list)
# How many elements are in this pandas dataframe?
df.size # including missing values
df.count() # excluding missing values
# How many elements are in this numpy array?
ndarray.size
# How many elements are in this array?
array.length
array.count
array.size
# How many rows are in this Active Record table?
table.count
-- How many elements are in this PostgreSQL array?
array_length(array, 1)
-- How many elements are in this DuckDB list?
len(list)
-- How many rows are in this table?
select count(*) from table
# How many elements are in this list?
length(list)