forked from codebasics/py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
learnp
committed
Jan 21, 2017
1 parent
d56d563
commit 72565f9
Showing
27 changed files
with
2,638 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.pyc | ||
.idea/ | ||
**/.idea/ | ||
.ipynb_checkpoints/ | ||
**/.ipynb_checkpoints/ | ||
**/.cache/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import time | ||
def time_it(func): | ||
def wrapper(*args, **kwargs): | ||
start = time.time() | ||
result = func(*args,**kwargs) | ||
end = time.time() | ||
print(func.__name__ +" took " + str((end-start)*1000) + "mil sec") | ||
return result | ||
return wrapper | ||
|
||
@time_it | ||
def calc_square(numbers): | ||
result = [] | ||
for number in numbers: | ||
result.append(number*number) | ||
return result | ||
|
||
@time_it | ||
def calc_cube(numbers): | ||
result = [] | ||
for number in numbers: | ||
result.append(number*number*number) | ||
return result | ||
|
||
array = range(1,100000) | ||
out_square = calc_square(array) | ||
out_cube = calc_cube(array) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sum: 14 | 6,8 | ||
sum: 13 | 7,6 | ||
sum: 10 | 2,8 | ||
sum: 14 | 9,5 | ||
sum: 15 | 9,6 |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
s = "I work in bloomberg founded by bloomberg work work" | ||
|
||
tokens = s.split(" ") | ||
d = {} | ||
for token in tokens: | ||
if token in d: | ||
d[token] += 1 | ||
else: | ||
d[token] = 1 | ||
|
||
print(d) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pandas as pd | ||
|
||
stats = { | ||
'Month': ['Jan', 'Feb', 'March', 'April'], | ||
'Expenses': [2350, 3400, 2700, 2200], | ||
'Income': [4000, 4000, 4000, 4000] | ||
} | ||
|
||
df = pd.DataFrame(stats) | ||
# df = df.set_index('Month') | ||
print(df.Month) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Pandas Tutorial On Stock Price Analysis | ||
|
||
# This tutorial will cover how to retrieve stock price from google finance using pandas data reader. The analysis of stock is done by plotting its high, low, close, volumne values in table and a chart. Charts are of two types, | ||
# | ||
# 1. Line Chart | ||
# 2. Bar Chart | ||
# | ||
# If you don't know what is stock then first **watch this video to gain understanding on fundamentals of stocks and investing**, | ||
# https://www.youtube.com/embed/XRO6lEu9-5w | ||
|
||
import pandas.io.data as web | ||
df = web.DataReader('AAPL', 'google', '2016/1/1', '2017/1/1') | ||
df.head() | ||
df.plot(y='Close', color="Green") | ||
df.plot.bar(y='Volume') | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import matplotlib.pyplot as plt | ||
x = [1,2,3] | ||
y = [50,55,40] | ||
plt.plot(x,y) | ||
plt.xlabel('Day') | ||
plt.ylabel('Temperature') | ||
plt.title('Weather Chart') | ||
plt.show() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import numpy as np | ||
|
||
a=np.array([[1,2,3],[4,5,6]]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import numpy as np | ||
import time | ||
import sys | ||
SIZE = 1000000 | ||
l1 = range(SIZE) | ||
l2 = range(SIZE) | ||
a1=np.arange(SIZE) | ||
a2=np.arange(SIZE) | ||
|
||
# python list | ||
start = time.time() | ||
result = [(x+y) for x,y in zip(l1,l2)] | ||
print("python list took: ",(time.time()-start)*1000) | ||
# numpy array | ||
start= time.time() | ||
result = a1 + a2 | ||
print("numpy took: ", (time.time()-start)*1000) | ||
|
||
|
Oops, something went wrong.