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
| ratings <- list("G", "NC-17", "PG", "PG-13", "R") | |
| genres <- | |
| list("Action", "Adventure", "Black Comedy", "Comedy", "Concert/Performance", | |
| "Documentary", "Drama", "Horror", "Musical", "Romantic Comedy", | |
| "Thriller/Suspense", "Western") | |
| base <- | |
| alt$Chart(vega_data$movies$url, width = 200, height = 200)$ | |
| mark_point(filled = TRUE)$ | |
| transform_calculate( |
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
| In [12]: arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux']), | |
| ....: np.array(['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two'])] | |
| ....: | |
| In [13]: s = pd.Series(np.random.randn(8), index=arrays) | |
| In [14]: s | |
| Out[14]: | |
| bar one -0.861849 | |
| two -2.104569 |
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
| . |
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
| for n in [0,1,2]: | |
| ...: print(np.random.randint(-1,1)) |
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
| x = ['month', | |
| '601800.SH', | |
| '300011.SZ', | |
| '300200.SZ', | |
| '000920.SZ', | |
| '600458.SH', | |
| '600580.SH', | |
| '600967.SH', | |
| '300150.SZ', | |
| '600495.SH', |
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([('bird', 'Falconiformes', 389.0), | |
| ...: ...: ('bird', 'Psittaciformes', 24.0), | |
| ...: ...: ('mammal', 'Carnivora', 80.2), | |
| ...: ...: ('mammal', 'Primates', np.nan), | |
| ...: ...: ('mammal', 'Carnivora', 58)], | |
| ...: ...: index=['falcon', 'parrot', 'lion', 'monkey', 'leopard'], | |
| ...: ...: columns=('class', 'order', 'max_speed')) | |
| df.groupby('class').groups | |
| df.groupby('class').describe() |
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
| import numpy as np | |
| import pandas as pd | |
| a = pd.DataFrame(np.random.randint(0,100,size=(20,5)),columns=list('sweet')) | |
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 WindPy import * | |
| w.start() | |
| _,s = w.edb("S0213383,S0213384,M5417758", "2010-04-16", "2019-04-16","Fill=Previous",usedf=True) | |
| import matplotlib.pyplot as plt | |
| from datetime import datetime as dt | |
| import os | |
| now =dt.now().strftime('%Y%m%d_%H_%M_%S') | |
| fig = plt.figure() | |
| ax =fig.add_subplot(111) |
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
| import matplotlib.pyplot as plt | |
| from datetime import datetime as dt | |
| import os | |
| now =dt.now().strftime('%Y%m%d_%H_%M_%S') | |
| fig = plt.figure() | |
| ax =fig.add_subplot(111) | |
| s.iloc[:,0].plot(ax=ax) | |
| s.iloc[:,1].plot(secondary_y=True) | |
| ax.set_ylabel('市值') | |
| ax.right_ax.set_ylabel('价格') |
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
| import matplotlib.pyplot as plt | |
| from datetime import datetime as dt | |
| import os | |
| now =dt.now().strftime('%Y%m%d_%H_%M_%S') | |
| fig = plt.figure() | |
| ax = fig.add_subplot(211) | |
| data = pd.Series(np.random.randn(500),name='random 500') | |
| data.plot(kind='kde',color='b',alpha=.6,ax=ax) #需要scipy.stats包 | |
| #以下使用的是matplot的方法 | |
| data.hist(color='b',alpha=.6,ax=ax,normed=True) |
NewerOlder