pandas データフレームの行数を取得するには、いくつかの方法があります。
私の質問は; ファイルの行数を知るだけで実際の行数を取得できますか? そうでない場合、データフレームをロードせずに行数を見つける方法の 1 つは何ですか?
これは、行数と行数を同じにすることができた状況です。
...
s1 = len(df.index) # get the row count.
with open(filename) as f: # open a file and count the lines, actual line count is 6377
for i, l in enumerate(f):
pass
s2 = i + 1 # row count
s2 = s2 - 2 # line count -2
出力:
s1 = {int} 6375
s2 = {int} 6375