Skip to main content
Data Science Wizardry Blog by Attila Vajda

If a morning is sunlit at autumn.

~/PROJECTS $ grep -r -o -w -h -E "\b\w+\(" ./Datasci/ | sort | uniq -c | sort -nr | head -n 100
17033 array(
9822 url(
8518 parametrize(
6748 DataFrame(
5592 Symbol(
4602 Matrix(
3905 ValueError(
3903 symbols(
3054 Series(
2726 exp(
...

The first 10 most used functions in the /numpy, /scikit-learn, /pandas, /matplotlib and /sympy directories.

$ print("\n".join[(x,y) for x in range(3)])
-bash: syntax error near unexpected token `"\n".join['

Simplifying the one liner shows here join() is written in the form join[], hence the error message.

$ [x*2 for x in range(3)]
-bash: syntax error near unexpected token `('

No wonder this Python one liner is not working in Bash. 🦕

>>> print([(x, y) for x in range(3)])
Traceback (most recent call last)
  File "<stdin>", line 1, in <module
  File "<stdin>", line 1, in <listcomp>
NameError: name 'y' is not defined

It seems like y must be given a value, because writing y in the expression part of the list comprehension returns with an error.

>>> print([(x, 0) for x in range(3)])
[(0, 0), (1, 0), (2, 0)]

Replacing y with an integer allows the program to run to completion, but the y coordinate is now a constant.