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
| def flatten(x): | |
| if hasattr(x, '__iter__') and not isinstance(x, str): | |
| for y in x: | |
| yield from flatten(y) | |
| else: | |
| yield x |
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
| def flatten(x): | |
| if hasattr(x, '__iter__') and not isinstance(x, str): | |
| for y in x: | |
| yield from flatten(y) | |
| else: | |
| yield x |
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
| trace = Bar(x=list(range(10)), y=list(np.random.randint(0,30,10))) | |
| data = Data([trace]) | |
| py.image.save_as(data, filename='bar.png') |
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 plotly.plotly as py | |
| from plotly.graph_objs import * | |
| trace0 = Scatter( | |
| x=[1, 2, 3, 4], | |
| y=[10, 15, 13, 17] | |
| ) | |
| trace1 = Scatter( | |
| x=[1, 2, 3, 4], |
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 msvcrt | |
| def inp(): | |
| w = [] | |
| while True: | |
| w.append(msvcrt.getwch()) | |
| if w[-1] == '\x10': break | |
| return ''.join(w[:-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
| In [175]: for i in range(len(df.mean().index)): | |
| .....: plt.bar(i, df.mean().iloc[i].gross, label=df.mean().index[i], color='0.{0}1'.format(i)) | |
| .....: | |
| In [176]: plt.legend(loc='best') | |
| Out[176]: <matplotlib.legend.Legend at 0xc5c1770> | |
| In [177]: plt.show() |
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 sys | |
| import math | |
| def compass(n): | |
| cells = math.ceil(math.sqrt(n)) | |
| maps = [[[] for _ in range(cells)] for __ in range(cells)] | |
| row = math.ceil(cells//2) | |
| col = row if cells%2 == 0 else row + 1 | |
| pos = 'S' | |
| direction = { |
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 s in ('C-c', 'C-s', 'C-r'): | |
| ... print(s) | |
| ... msvcrt.getch() | |
| ... | |
| C-c | |
| b'\x03' | |
| C-s | |
| b'\x13' | |
| C-r | |
| b'\x12' |
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='Supercalifragilisticexpialidocious';[print(''.join(__import__('random').sample(s,len(s)))) for _ in s] |
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
| Supercalifragilisticexpialidocious = lambda x: ''.join(random.sample(x ,len(x)) |