首页 > 其他分享 >利用pandas 判断csv文件最大长度

利用pandas 判断csv文件最大长度

时间:2022-08-31 17:58:46浏览次数:43  
标签:mirrors df max col 长度 csv pandas

1.安装pandas

pip install pandas -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com/pypi/simple

 

import pandas as pd

df = pd.read_csv(r'C:\Users\admin\Desktop\国家信息数据 csv\DEA_PURCHASE_ANNO.csv')

for i, col in enumerate(df.columns.tolist()):
    df[col] = df[col].astype(str)
    n_max = df[col].str.len().max()
    print(i, n_max)

 

标签:mirrors,df,max,col,长度,csv,pandas
From: https://www.cnblogs.com/kanbujiandeheiye/p/16644003.html

相关文章