问题描述
如果文件有 'SOURCE' 列,则:如果 lambda len().max() 'SOURCE' 列 > 0,我们可以得出结论不为空,然后按照 代码...
但是!!如果“SOURCE”列是空的,它告诉我是一个“浮点数”,因此它没有错误形式的长度。我只是想过滤:如果“SOURCE”列是空的,不是逐行而是整列,那么就这样做...
for f in files_xlsx:
wb = load_workbook(input_path + "\\" + f,read_only=True)
if 'New Leads' in wb.sheetnames:
df = pd.read_excel(input_path + "\\" + f,sheet_name="New Leads")
colre = [col for col in df.columns]
for eo in colre:
df.rename(columns={eo: eo.replace('*','').replace('**','') for eo in colre})
dtcol = [col for col in df.columns if "Date" in col]
for ex in dtcol:
df.rename(columns={ex: "Activity Date"},inplace=True)
cols = df.columns
if "SOURCE" in cols:
if df.dtypes['SOURCE'] != 'float':
if df.soURCE.map(lambda x: len(x)).max() > 0:
df.dropna(how = 'all')
df['File'] = f
df_xlsx = pd.concat([df,df_xlsx],ignore_index=True)
df_xlsx = df_xlsx[["Email","SOURCE","File","Activity Date"]]
else:
df_ns = df_ns.append([f],ignore_index=True)
else:
df_ns = df_ns.append([f],ignore_index=True)
else:
df_ns = df_ns.append([f],ignore_index=True)
else:
df_ns = df_ns.append([f],ignore_index=True)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)