有几种方法可以获取 pandas 数据帧的行数。
我的问题是;我可以通过简单地知道文件的行数来获得实际的行数吗?如果没有,我可以找到行数而无需加载数据框的一种方法是什么?
这是我能够使行数和行数相同的情况。
...
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