报错:Traceback (most recent call last):
File "E:2.py", line 61, in
print(df['用人单位列席'].unique())
TypeError: 'function' object is not subscriptable
内容:
import pandas as pd
from pyecharts.charts import *
from numpy import array
import numpy as np
df = pd.read_excel('E:\python文件夹\职位列表.xlsx')
print(df)
print(df.head(5))
# 处理异常值
print(df['所需经验'].unique())
print(df["所需经验"].replace('其他', '无需经验', inplace=True))
df_1 = df["所需经验"].value_counts()
print(df_1)
print(df['所需学历'].unique())
print(df["所需学历"].replace('招1人', '所需学历不限', inplace=True))
df_2 = df["所需学历"].value_counts()
print(df_2)
# # 薪水处理
print(df['薪水'].unique())
print(df.isnull())
df_3 = df["薪水"].value_counts()
print(df_3)
# print(df.isnull.sum())
df['bottom'] = df['薪水'].str.extract('^(.*?)-.*?')
print(df['bottom'])
df['top'] = df['薪水'].str.extract('^.*?-(\d\.\d|\d)')
print(df['top'])
print(df.info())
df['bottom'] = df['bottom'].astype('float64')
print(df['bottom'])
df['top'] = df['top'].astype('float64')
print(df['top'])
print(df.info())
# 填补缺失值\删除
df.dropna(subset=['薪水'], inplace=True)
print(df.dropna(subset=['薪水'], inplace=True))
# # 薪水区间
def df(first, end, step):
x = []
for i in np.arange(first, end, step):
x.append(i)
return x
list_1 = df(0, 30, 0.5)
print(list_1)
# print(df['top'].plot.hist(bins=30))
# print(plt.show())
print(df['用人单位列席'].unique())
print(df.isnull())
df_4 =(df["用人单位列席"].value_counts())
print(df_4)
print(df['用人单位类型'].unique())
print(df.isnull())
df_5 =(df["用人单位类型"].value_counts())
print(df_5)
print(df['所在城市'].unique())
print(df.isnull())
df_6 =(df["所在城市"].value_counts())
print(df_6)