python基础-9-数据分析python——pandas——r

2019-03-23  本文已影响0人  比特跃动

注意1:准备要读取的csv文件要与Jupyter的ipython文件目录一致。

注意2:读取utf文件会省事很多,千万别弄gbk格式,麻烦容易出错,但是可以通过改encoding也可以解决相关问题。能省事就省事,没必要麻烦了。




示例



//input1
import pandas as pd
df=pd.read_csv('DataAnalyst_utf.csv')
df.info()

//output1
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5031 entries, 0 to 5030
Data columns (total 12 columns):
positionId           5031 non-null int64
city                 5031 non-null object
companyId            5031 non-null int64
firstType            5027 non-null object
secondType           5028 non-null object
education            5031 non-null object
industryField        5031 non-null object
positionAdvantage    5031 non-null object
positionName         5031 non-null object
positionLables       5007 non-null object
salary               5031 non-null object
workYear             5031 non-null object
dtypes: int64(2), object(10)
memory usage: 471.7+ KB








//input2
df.head(2)

//output2
    positionId  city    companyId   firstType   secondType  education   industryField   positionAdvantage   positionName    positionLables  salary  workYear
0   2537336 上海  8581    技术  数据开发    硕士  移动互联网   知名平台    数据分析师   ['分析师', '数据分析', '数据挖掘', '数据']   7k-9k   应届毕业生
1   2427485 上海  23177   技术  数据开发    本科  金融  挑战机会,团队好,与大牛合作,工作环境好    数据分析师-CR2017-SH2909 ['分析师', '数据分析', '数据挖掘', '数据']   10k-15k 应届毕业生









//input3
df.tail(2)

//output3

positionId  city    companyId   firstType   secondType  education   industryField   positionAdvantage   positionName    positionLables  salary  workYear
5029    2582349 北京  156832  市场/商务/销售类   销售  不限  金融  周末双休/高提成/每月员工趴  分析师助理/销售人员  ['顾问', '销售', '分析师'] 4k-6k   不限
5030    1757974 北京  1575    技术  高端技术职位  本科  移动互联网,数据服务  大公司,高福利,互联网数据团队,机会多 数据仓库建模工程师   ['数据仓库', '数据', '建模']    15k-30k 不限

//input4
df.positionId = df.positionId.astype('str')
df.info()

//output4
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5031 entries, 0 to 5030
Data columns (total 12 columns):
positionId           5031 non-null object
city                 5031 non-null object
companyId            5031 non-null int64
firstType            5027 non-null object
secondType           5028 non-null object
education            5031 non-null object
industryField        5031 non-null object
positionAdvantage    5031 non-null object
positionName         5031 non-null object
positionLables       5007 non-null object
salary               5031 non-null object
workYear             5031 non-null object
dtypes: int64(1), object(11)
memory usage: 471.7+ KB
上一篇下一篇

猜你喜欢

热点阅读