Created
October 21, 2022 15:48
-
-
Save mh0w/6a4af4494cae872dd44093782c9e9a86 to your computer and use it in GitHub Desktop.
pandas: dataframes: count rows or columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.DataFrame(columns=['A','B','C','D','E','F','G']) | |
# rows | |
print(len(df.index)) # 0 - slightly faster in large dfs | |
print(df.shape[0]) # 0 | |
# columns | |
print(len(df.columns)) # 7 | |
print(df.shape[1]) # 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment