Last active
November 26, 2016 14:33
-
-
Save u1and0/53f28ede97164d2b3ace7ce0061df183 to your computer and use it in GitHub Desktop.
pythonで作るサンプルデータ ref: http://qiita.com/u1and0/items/0625f7a1cd9b476270bb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n=20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = np.arange(n).reshape(4, -1); a # 5列の行列 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plt.contourf(df, cmap='jet') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.contour.QuadContourSet at 0x1769a1a12b0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plt.pcolor(df, cmap='jet') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.collections.PolyCollection at 0x1769b1e2208> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n=100 | |
| x = np.linspace(0, 2*np.pi, n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s = pd.Series(np.sin(x), index=x) | |
| s.plot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x1769e695780> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snoise = s + 0.1 * np.random.randn(n) | |
| sdf = pd.DataFrame({'sin wave':s, 'noise wave': snoise}) | |
| sdf.plot(color=('r', 'b')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x1769e8586d8> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scipy import stats as ss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | |
| 17, 18, 19, 20, 21, 22, 23, 24], | |
| [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, | |
| 42, 43, 44, 45, 46, 47, 48, 49], | |
| [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, | |
| 67, 68, 69, 70, 71, 72, 73, 74], | |
| [75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, | |
| 92, 93, 94, 95, 96, 97, 98, 99]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| median = x[int(n/2)] # xの中央値 | |
| g = pd.Series(ss.norm.pdf(x, loc=median), x) | |
| g.plot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x1769ffba128> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gnoise = g + 0.01 * np.random.randn(n) | |
| df = pd.DataFrame({'gauss wave':g, 'noise wave': gnoise}) | |
| df.plot(color=('r', 'b')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x1769e970828> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| median = x[int(n/2)] # xの中央値 | |
| x1 = x + 10e-3 | |
| l = pd.Series(np.log(x1), x1) | |
| l.plot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x1769ffba5f8> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lnoise = l + 0.1 * np.random.randn(n) | |
| df = pd.DataFrame({'log wave':l, 'noise wave': lnoise}) | |
| df.plot(color=('r', 'b')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x176a00ec358> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = 1000 | |
| se = pd.Series(np.random.randint(-1, 2, n)).cumsum() | |
| se.plot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x284f3c62c18> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.DataFrame(a, columns=list('abcde')); df |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sma100 = se.rolling(100).mean() | |
| ema100 = se.ewm(span=100).mean() | |
| df = pd.DataFrame({'Chart': se, 'SMA100': sma100, 'EMA100': ema100}) | |
| df.plot(style = ['--','-','-']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x284f3cadcc0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| r = np.random.randn(4, 5); r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array([[-0.37840346, -0.84591793, 0.50590263, 0.0544243 , 0.59361247], | |
| [-0.2726931 , -1.74415635, 0.0199559 , -0.20695113, -1.19559455], | |
| [-0.59799566, -0.26810224, -0.18738038, 1.05843686, 0.72317579], | |
| [ 1.23389386, 1.91293041, -1.33322818, 0.78255026, 2.04737357]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.DataFrame(r, columns=list('abcde')); df |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df.plot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <matplotlib.axes._subplots.AxesSubplot at 0x17699af2a58> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.DataFrame(np.random.randn(n,n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment