This file contains 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
select count(case when status='200 OK') as ok,count(case when status!='200 OK') as error from date_status group by time; |
This file contains 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.image as mpimg | |
import glob | |
import os | |
def load_data(dir_name = 'plates'): | |
""" Your implementation """ | |
data_path = os.path.join(dir_name, '*g') | |
files = glob.glob(data_path) | |
data = [mpimg.imread(img) for img in files] | |
return data |
This file contains 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 | |
df = pd.DataFrame( | |
{ | |
'AAA': [1,1,1,2,2,2,2,3,3], | |
'BBB': [2,1,3,4,5,1,2,3,7] | |
} | |
) | |
print(df,'\n') |
This file contains 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 os.path | |
import my_module | |
print(os.path.abspath(my_module.__file__)) |
This file contains 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 get_one_hot(targets, nb_classes): | |
return np.eye(nb_classes)[np.array(targets).reshape(-1)] | |
This is what happens: | |
np.eye(3) | |
array([[ 1., 0., 0.], | |
[ 0., 1., 0.], | |
[ 0., 0., 1.]]) |
This file contains 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
Set a subplots. Display image and title inside a for-loop. | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
from matplotlib.pyplot import imshow | |
fig, axs = plt.subplots(2,5, figsize=(15, 6), facecolor='w', edgecolor='k') | |
fig.subplots_adjust(hspace = .5, wspace=.001) | |
axs = axs.ravel() |
This file contains 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
<img src="images/1.png" alt="Drawing" style="width: 800px;"/> |
This file contains 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
correct_prediction = tf.equal(tf.argmax(logits, 1), tf.argmax(labels, 1)) | |
#tf.argmax finds the index of the largest value along axis = 1.tf.equal checks whether the two are equal, if the output index (predicted classes are the same, then correct prediction is 1). |
This file contains 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
1.Remove duplicates in a list | |
cleanlist = [] | |
for n in oldlist: | |
if n not in cleanlist: | |
cleanlist.append(n) |
This file contains 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
1. Substitute the NaN's in a dataframe with values from another dataframe | |
If you have two DataFrames of the same shape, then: | |
df[df.isnull()] = d2 | |
2.Replace values in a dataframe with values from another dataframe by conditions |
NewerOlder