Skip to content

Commit 72565f9

Browse files
author
learnp
committed
added pands first tutorial
1 parent d56d563 commit 72565f9

27 files changed

+2638
-2
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.pyc
2+
.idea/
3+
**/.idea/
4+
.ipynb_checkpoints/
5+
**/.ipynb_checkpoints/
6+
**/.cache/

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/py.iml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Advanced/decorators.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
def time_it(func):
3+
def wrapper(*args, **kwargs):
4+
start = time.time()
5+
result = func(*args,**kwargs)
6+
end = time.time()
7+
print(func.__name__ +" took " + str((end-start)*1000) + "mil sec")
8+
return result
9+
return wrapper
10+
11+
@time_it
12+
def calc_square(numbers):
13+
result = []
14+
for number in numbers:
15+
result.append(number*number)
16+
return result
17+
18+
@time_it
19+
def calc_cube(numbers):
20+
result = []
21+
for number in numbers:
22+
result.append(number*number*number)
23+
return result
24+
25+
array = range(1,100000)
26+
out_square = calc_square(array)
27+
out_cube = calc_cube(array)

Basics/input.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sum: 14 | 6,8
2+
sum: 13 | 7,6
3+
sum: 10 | 2,8
4+
sum: 14 | 9,5
5+
sum: 15 | 9,6

Basics/test.ipynb

+486
Large diffs are not rendered by default.

Basics/word_occurences.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
s = "I work in bloomberg founded by bloomberg work work"
2+
3+
tokens = s.split(" ")
4+
d = {}
5+
for token in tokens:
6+
if token in d:
7+
d[token] += 1
8+
else:
9+
d[token] = 1
10+
11+
print(d)

Modules/pandas_tutorial.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pandas as pd
2+
3+
stats = {
4+
'Month': ['Jan', 'Feb', 'March', 'April'],
5+
'Expenses': [2350, 3400, 2700, 2200],
6+
'Income': [4000, 4000, 4000, 4000]
7+
}
8+
9+
df = pd.DataFrame(stats)
10+
# df = df.set_index('Month')
11+
print(df.Month)

jupyter/jupyter_architecture.png

82.3 KB
Loading

jupyter/jupyter_stocks.ipynb

+262
Large diffs are not rendered by default.

jupyter/pandas_tutorial_on_stock_price.ipynb

+491
Large diffs are not rendered by default.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Pandas Tutorial On Stock Price Analysis
2+
3+
# 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,
4+
#
5+
# 1. Line Chart
6+
# 2. Bar Chart
7+
#
8+
# If you don't know what is stock then first **watch this video to gain understanding on fundamentals of stocks and investing**,
9+
# https://www.youtube.com/embed/XRO6lEu9-5w
10+
11+
import pandas.io.data as web
12+
df = web.DataReader('AAPL', 'google', '2016/1/1', '2017/1/1')
13+
df.head()
14+
df.plot(y='Close', color="Green")
15+
df.plot.bar(y='Volume')
16+

jupyter/python_pandas_notebook.ipynb

+331
Large diffs are not rendered by default.

matpltlib/plt_intro.ipynb

+89
Large diffs are not rendered by default.

matpltlib/plt_introduction.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import matplotlib.pyplot as plt
2+
x = [1,2,3]
3+
y = [50,55,40]
4+
plt.plot(x,y)
5+
plt.xlabel('Day')
6+
plt.ylabel('Temperature')
7+
plt.title('Weather Chart')
8+
plt.show()

numpy/numpy_tutorail_2.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import numpy as np
2+
3+
a=np.array([[1,2,3],[4,5,6]])

numpy/numpy_tutorial.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
import time
3+
import sys
4+
SIZE = 1000000
5+
l1 = range(SIZE)
6+
l2 = range(SIZE)
7+
a1=np.arange(SIZE)
8+
a2=np.arange(SIZE)
9+
10+
# python list
11+
start = time.time()
12+
result = [(x+y) for x,y in zip(l1,l2)]
13+
print("python list took: ",(time.time()-start)*1000)
14+
# numpy array
15+
start= time.time()
16+
result = a1 + a2
17+
print("numpy took: ", (time.time()-start)*1000)
18+
19+

0 commit comments

Comments
 (0)