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 = set({3,1,2,3}) | |
print(type(a)) | |
>> <class 'set'> | |
print(a) #Order and Repetition dosent matter in sets | |
>> {1, 2, 3} |
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 generate_counts(coin_flips=1000, n=1000): | |
x = 2*(np.random.random((coin_flips, n)) > 0.5) - 1 #generates a 1000x1000 matrix, 1 for heads -1 for tails | |
s = x.sum(axis=0) #summing row wise, 1000 coin flips for 1000 times together | |
return s |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pandas as pd | |
time_format = '%Y-%m-%d %H%M%S' | |
date = ['2015-01-01 091234','2015-01-01 091234'] | |
time_format_date = pd.to_datetime(date,format=time_format) | |
print(time_format_date) | |
>> DatetimeIndex(['2015-01-01 09:12:34', '2015-01-01 09:12:34'], dtype='datetime64[ns]', freq=None) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.random.randint(5,10,5) | |
>> a | |
[6 5 8 8 7] | |
np.add.at(a,np.flatnonzero(a>8),2) #flatnonzero returns the indices where values are >8 | |
>> a | |
[6 5 10 10 9] | |
np.maximum.at(a,[0,1,2],60) #checks the max value | |
>> a |
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
ages = np.random.randint(10,50,10) | |
heights = np.random.randint(120,210,10) | |
>> ages | |
[24 22 13 26 31 20 29 32 34 19] | |
>> heights | |
[146 141 166 191 169 203 149 135 170 152] | |
sorter = np.argsort(ages) |
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(2,10,2) | |
print(a) | |
>> [2 4 6 8] | |
print(a>5) | |
>> [False False True True] | |
b = np.flatnonzero(a>1) | |
print(b) | |
>> [2 3] |