提取字符串中的数字和将dataframe中的某列分类计数

提取字符串中的数字
import re
f_v = eval(re.sub("D", "", Version[:3]))


列分类计数
1、转换成dataframe
df_fdd_ = pd.pivot_table(df_fdd, index=['CELL'], values=["NE"], aggfunc=['count'])
df0 = pd.DataFrame(data=[df_fdd_.index, df_fdd_.iloc[:, 0]]).T
df0.columns = ['CELL', 'nums'] # 为新的dataframe设定列标题
------------------------------------------------------------
df_new = pd.DataFrame(_fdd_).reset_index()
2、列表推导式
list = [cell for cell in df_fdd["CELL"].value_counts().items()]



原文地址:https://www.cnblogs.com/huangyz-xy/p/13291559.html