Skip to content

Commit 086aa49

Browse files
committed
submit code
1 parent 683f0a6 commit 086aa49

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

chaoxi/Pandas1/pandas_example.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pandas as pd
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
5+
def craw_bar():
6+
df2 = pd.DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd'])
7+
df2.plot.bar()
8+
plt.show()
9+
10+
def craw_line():
11+
ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000))
12+
ts = ts.cumsum()
13+
ts.plot()
14+
plt.show()
15+
16+
def craw_line1():
17+
ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000))
18+
df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list("ABCD"))
19+
df = df.cumsum()
20+
df.plot()
21+
plt.show()
22+
23+
24+
def craw_bar():
25+
ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000))
26+
df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list("ABCD"))
27+
plt.figure()
28+
df.iloc[5].plot(kind="bar")
29+
plt.show()
30+
31+
def craw_bar1():
32+
df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"])
33+
df2.plot.bar()
34+
plt.show()
35+
36+
def craw_bar2():
37+
df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"])
38+
df2.plot.bar(stacked=True)
39+
plt.show()
40+
41+
def craw_bar3():
42+
df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"])
43+
df2.plot.barh(stacked=True)
44+
plt.show()
45+
46+
if __name__ == '__main__':
47+
craw_bar3()

chaoxi/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Python技术 公众号文章代码库
77

88
![](http://favorites.ren/assets/images/python.jpg)
99

10-
## 实例代码
10+
## 实例代码
11+
12+
[神器 Pandas 绘图大全(上)!](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/Pandas1) 神器 Pandas 绘图大全(上)!
1113

1214
[神器-可视化分析之Basemap实战详解(二)](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/BaseMap) 神器-可视化分析之Basemap实战详解(二)
1315

0 commit comments

Comments
 (0)