Pandas数据分析库
粉皮皮
这个作者很懒,什么都没留下…
展开
-
Pandas plot
import pandas as pd import numpy as np import matplotlib.pylot as plt data = pd.Series(np.random.randint(1000), index=np.arange(1000)) data = data.cumsum() data.plot() plt.show() data = pd.Series(np.random.randint(1000), index=np.arange(1000), columns =['A原创 2021-07-13 21:21:09 · 108 阅读 · 0 评论 -
Pandas合并_merge
import pandas as pd import numpy as np left = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3'], 'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3']}) right = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3'],原创 2021-07-13 17:43:10 · 86 阅读 · 0 评论 -
Pandas的合并
import pandas as pd import numpy as np df1 = pd.DataFrame(np.arange(12).reshape(3, 4), columns=['A', 'B', 'C', 'D']) df2 = pd.DataFrame(np.arange(12, 24).reshape(3, 4), columns=['A', 'B', 'C', 'D']) df3 = pd.DataFrame(np.arange(24, 36).reshape(3, 4), colum原创 2021-07-13 16:22:58 · 83 阅读 · 0 评论 -
Pandas文件读取与写入
import pandas as pd file = pd.read_csv('pepole.csv', encoding='gbk') print(file) file.iloc[2, 0] = '深圳' print(file) file.to_csv('pepole2.csv')原创 2021-07-13 10:48:34 · 108 阅读 · 0 评论 -
Pandas处理丢失数据
import pandas as pd import numpy as np dates = np.arange(20210712, 20210716) df1 = pd.DataFrame(np.arange(12).reshape(4, 3), index=[dates], columns=['A', 'B', 'C']) print(df1) df2 = pd.DataFrame(df1, index=[dates], columns=['A', 'B', 'C', 'D', 'E']) print(原创 2021-07-12 21:42:54 · 88 阅读 · 0 评论 -
Padans赋值及操作
import pandas as pd import numpy as np dates = np.arange(20210712, 20210718) df1 = pd.DataFrame(np.arange(24).reshape(6, 4), index=[dates], columns=['A', 'B', 'C', 'D']) print(df1) print() print(df1.iloc[2, 2]) # 位置的方式 print() df1.iloc[2, 2]=100 print(df1原创 2021-07-12 16:52:46 · 171 阅读 · 0 评论 -
Pandas选择数据
import pandas as pd import numpy as np dates = pd.date_range('20210712', periods=6) df1 = pd.DataFrame(np.arange(24).reshape(6, 4), index=[dates], columns=['A', 'B', 'C', 'D']) print(df1) print() print(df1['A']) # 将DataFrame的一个列获取为一个Series print(df1.A) #原创 2021-07-12 11:29:05 · 87 阅读 · 0 评论 -
pandas基础,Series(一维序列),Dataframe(二维表结构)
import pandas as pd import numpy as np # Series s1 = pd.Series([4, 7, -5, 3]) # 创建一个series,索引为默认值 print(s1) print() print(s1.values) # Series的值 print(s1.index) # Series的索引 print() s2 = pd.Series([4.0, 6.5, -0.5, 4.2], index=['d', 'b', 'a', 'c']) print(s原创 2021-07-12 10:44:55 · 521 阅读 · 0 评论