我试图读取固定宽度格式的文件,并通过在函数中使用正则表达式来标识它们来跳过可变数量的页眉和页脚行。我正在使用python3.7和pandas 0.25.1:
var value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 0 : value;
value++;
shared(value);
document.getElementById('number').value = value;
var value = parseInt(document.getElementById('number').value, 10);
if(value>= STRONG.share){
window.location="/result.html";
这是数据文件的示例
import re
import pandas as pd
class Skewt():
def create_skewt(self, datafile):
# Read in the column names from the header. For a description, see:
# http://weather.uwyo.edu/upperair/columns.html
col_names = pd.read_fwf(datafile, header=4, nrows=1).columns
col_names = col_names[0].split()
print(col_names)
# Read the data from the data file into a pandas dataframe
# Only read in columns we need [P, T, Td], and skip header and footer
# lines (identified by having letters or 2 or more dashes)
header = re.compile(r'[A-Za-z-][A-Za-z-]')
rdat = pd.read_fwf(datafile, skiprows= lambda x: x in header.match(x),
usecols=[0, 2, 3], names=col_names)
if __name__ == "__main__":
datafile = "../../test/data/726722019052812.ctrl.mtp"
skewt = Skewt()
skewt.create_skewt(datafile)
plt.show()
我跑步时出现此错误:
TypeError:“函数”类型的参数不可迭代
两年前的这个问题Pandas read_fwf error when skiprows is a function建议更新熊猫,但我相信我拥有最新版本。
是否已删除对回调的支持?还有其他我想念的东西吗? (我是熊猫新手。)