Merging two DataFrames

The error message indicates that df2 is of type pd.Series. You need to convert df2 .to_frame() as .merge() needs a pd.DataFrame() input (see docs): while you probably also just could: Alternatively, you can use pd.DataFrame.join() which accepts a pd.Series.

Purpose of #!/usr/bin/python3 shebang

#!/usr/bin/python3 is a shebang line. A shebang line defines where the interpreter is located. In this case, the python3 interpreter is located in /usr/bin/python3. A shebang line could also be a bash, ruby, perl or any other scripting languages’ interpreter, for example: #!/bin/bash. Without the shebang line, the operating system does not know it’s a python script, even if you set the execution flag (chmod … Read more

print(__doc__) in Python 3 script

it seems __doc__ is useful to provide some documentation in, say, functions This is true. In addition to functions, documentation can also be provided in modules. So, if you have a file named mymodule.py like this: You can access its docstrings like this: Now, back to your question: what does print(__doc__) do? Simply put: it prints the module docstring. If no … Read more