To print the number of columns in a dataframe in Python, you can use the shape attribute of the Pandas DataFrame object. The shape attribute returns a tuple with two elements: the number of rows and the number of columns. To print just the number of columns, you can access the second element of the tuple using indexing. Here's an example:
main.py259 chars12 lines
This will output:
main.py21 chars2 lines
gistlibby LogSnag