This class introduces this this this functions


In [5]:
# +, -, *, /
print(5/5)


1.0

In [9]:
my_num = 5.0

In [10]:
#types = int, float, str
type(my_num)


Out[10]:
float

In [24]:
my_name = "Hrant"
my_surname = "Davtyan"
my_full_name = my_name + " " + my_surname

In [25]:
print(my_full_name)


Hrant Davtyan

In [26]:
str(5)


Out[26]:
'5'

In [29]:
int("5")


Out[29]:
5

In [32]:
my_list = [[1],[2]]

In [33]:
type(my_list)


Out[33]:
list

In [35]:
print(my_full_name.upper())


HRANT DAVTYAN

In [36]:
full_name = [my_name,my_surname]

In [40]:
print(full_name[0:1])


['Hrant']

In [41]:
names = ["James","John","Jack","Jimmy"]

In [44]:
print(names[-2])


Jack

In [58]:
names_up = []
for i in names:
    names_up.append(i.upper())

In [59]:
names_up = [i.upper() for i in names]

In [61]:
print(names_up)


['JAMES', 'JOHN', 'JACK', 'JIMMY']

In [64]:
#square of interested with a loop and list comprehension
for i in range(1,11):
    print(i**2)


1
4
9
16
25
36
49
64
81
100

In [65]:
sqr_list = [i**2 for i in range(1,11)]

In [66]:
print(sqr_list)


[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

In [71]:
i=1
while i<11:
    print(i**2)
    i = i+2


1
9
25
49
81

In [83]:
a = 0
if a>3:
    print("Greater")
elif a==3:
    print("Equal")
else:
    print("Smaller")


Smaller

In [84]:
def superify(text):
    return "super"+text

In [88]:
superify("star")


Out[88]:
'superstar'

Libraries


In [89]:
import quandl

In [96]:
data = quandl.get("FRED/DDOE02USA086NWDB")

In [91]:
type(data)


Out[91]:
pandas.core.frame.DataFrame

In [97]:
# take a look to top 3 rows
data.head(3)


Out[97]:
Value
Date
1960-01-01 13.57
1961-01-01 13.72
1962-01-01 13.88

In [93]:
data.tail()


Out[93]:
Value
Date
2018-01-01 4.1
2018-02-01 4.1
2018-03-01 4.1
2018-04-01 3.9
2018-05-01 3.8

In [98]:
import pandas as pd

In [99]:
# head(), tail(), info(), describe()
data.info()


<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 56 entries, 1960-01-01 to 2015-01-01
Data columns (total 1 columns):
Value    56 non-null float64
dtypes: float64(1)
memory usage: 896.0 bytes

In [104]:
data.describe()


Out[104]:
Value
count 56.000000
mean 54.911786
std 31.979411
min 13.570000
25% 22.057500
50% 53.170000
75% 81.522500
max 108.700000

In [105]:
df = quandl.get("WIKI/AAPL")

In [106]:
type(df)


Out[106]:
pandas.core.frame.DataFrame

In [107]:
df.info()


<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 9400 entries, 1980-12-12 to 2018-03-27
Data columns (total 12 columns):
Open           9400 non-null float64
High           9400 non-null float64
Low            9400 non-null float64
Close          9400 non-null float64
Volume         9400 non-null float64
Ex-Dividend    9400 non-null float64
Split Ratio    9400 non-null float64
Adj. Open      9400 non-null float64
Adj. High      9400 non-null float64
Adj. Low       9400 non-null float64
Adj. Close     9400 non-null float64
Adj. Volume    9400 non-null float64
dtypes: float64(12)
memory usage: 954.7 KB

In [108]:
df.head(3)


Out[108]:
Open High Low Close Volume Ex-Dividend Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume
Date
1980-12-12 28.75 28.87 28.75 28.75 2093900.0 0.0 1.0 0.422706 0.424470 0.422706 0.422706 117258400.0
1980-12-15 27.38 27.38 27.25 27.25 785200.0 0.0 1.0 0.402563 0.402563 0.400652 0.400652 43971200.0
1980-12-16 25.37 25.37 25.25 25.25 472000.0 0.0 1.0 0.373010 0.373010 0.371246 0.371246 26432000.0

In [109]:
df.describe()


Out[109]:
Open High Low Close Volume Ex-Dividend Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume
count 9400.000000 9400.000000 9400.000000 9400.000000 9.400000e+03 9400.000000 9400.000000 9400.000000 9400.000000 9400.000000 9400.000000 9.400000e+03
mean 101.233437 102.466958 99.896250 101.194472 1.198560e+07 0.003633 1.000957 21.571019 21.774929 21.351252 21.567664 8.860156e+07
std 135.169307 136.294005 133.829528 135.087350 1.662310e+07 0.088269 0.064409 39.272529 39.584888 38.942651 39.271266 8.704777e+07
min 11.120000 11.120000 11.000000 11.000000 4.471000e+03 0.000000 1.000000 0.163495 0.163495 0.161731 0.161731 2.503760e+05
25% 27.000000 27.500000 26.500000 27.000000 1.232075e+06 0.000000 1.000000 0.923453 0.940280 0.904096 0.922730 3.461080e+07
50% 43.750000 44.500000 43.000000 43.880000 3.776200e+06 0.000000 1.000000 1.437461 1.468272 1.410762 1.437445 6.069700e+07
75% 110.120000 111.755000 108.747500 110.060000 1.808312e+07 0.000000 1.000000 20.270182 20.565604 19.905845 20.294924 1.109031e+08
max 702.410000 705.070000 699.570000 702.100000 1.895606e+08 3.290000 7.000000 182.590000 183.500000 180.210000 181.720000 1.855410e+09

In [113]:
#selecting column
opening_pirces_1 = df.Open
opening_pirces_2 = df["Open"]
opening_pirces_3 = df.iloc[:,1]

In [117]:
#rate = 0.86
df["New_Price"] = df*0.86


Out[117]:
Open High Low Close Volume Ex-Dividend Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume New_Price
Date
1980-12-12 24.7250 24.8282 24.725000 24.7250 1800754.00 0.0 0.86 0.363527 0.365044 0.363527 0.363527 1.008422e+08 21.263500
1980-12-15 23.5468 23.5468 23.435000 23.4350 675272.00 0.0 0.86 0.346204 0.346204 0.344560 0.344560 3.781523e+07 20.250248
1980-12-16 21.8182 21.8182 21.715000 21.7150 405920.00 0.0 0.86 0.320789 0.320789 0.319272 0.319272 2.273152e+07 18.763652
1980-12-17 22.2482 22.3600 22.248200 22.2482 331874.00 0.0 0.86 0.327111 0.328755 0.327111 0.327111 1.858494e+07 19.133452
1980-12-18 22.9018 23.0050 22.901800 22.9018 281994.00 0.0 0.86 0.336721 0.338238 0.336721 0.336721 1.579166e+07 19.695548
1980-12-19 24.2950 24.4068 24.295000 24.2950 186706.00 0.0 0.86 0.357205 0.358849 0.357205 0.357205 1.045554e+07 20.893700
1980-12-22 25.4818 25.5850 25.481800 25.4818 143448.00 0.0 0.86 0.374654 0.376172 0.374654 0.374654 8.033088e+06 21.914348
1980-12-23 26.5568 26.6600 26.556800 26.5568 180256.00 0.0 0.86 0.390460 0.391977 0.390460 0.390460 1.009434e+07 22.838848
1980-12-24 27.9500 28.0618 27.950000 27.9500 184298.00 0.0 0.86 0.410944 0.412587 0.410944 0.410944 1.032069e+07 24.037000
1980-12-26 30.5300 30.6332 30.530000 30.5300 213366.00 0.0 0.86 0.448877 0.450394 0.448877 0.448877 1.194850e+07 26.255800
1980-12-29 30.9600 31.0718 30.960000 30.9600 357674.00 0.0 0.86 0.455199 0.456843 0.455199 0.455199 2.002974e+07 26.625600
1980-12-30 30.3150 30.3150 30.203200 30.2032 264450.00 0.0 0.86 0.445716 0.445716 0.444072 0.444072 1.480920e+07 26.070900
1980-12-31 29.4550 29.4550 29.351800 29.3518 137256.00 0.0 0.86 0.433071 0.433071 0.431554 0.431554 7.686336e+06 25.331300
1981-01-02 29.6700 29.8850 29.670000 29.6700 83162.00 0.0 0.86 0.436233 0.439394 0.436233 0.436233 4.657072e+06 25.516200
1981-01-05 29.1282 29.1282 29.025000 29.0250 137170.00 0.0 0.86 0.428267 0.428267 0.426749 0.426749 7.681520e+06 25.050252
1981-01-06 27.8382 27.8382 27.735000 27.7350 173376.00 0.0 0.86 0.409300 0.409300 0.407783 0.407783 9.709056e+06 23.940852
1981-01-07 26.6600 26.6600 26.556800 26.5568 213796.00 0.0 0.86 0.391977 0.391977 0.390460 0.390460 1.197258e+07 22.927600
1981-01-08 26.1182 26.1182 26.015000 26.0150 152908.00 0.0 0.86 0.384011 0.384011 0.382494 0.382494 8.562848e+06 22.461652
1981-01-09 27.4168 27.5200 27.416800 27.4168 82560.00 0.0 0.86 0.403104 0.404621 0.403104 0.403104 4.623360e+06 23.578448
1981-01-12 27.4168 27.4168 27.193200 27.1932 90988.00 0.0 0.86 0.403104 0.403104 0.399817 0.399817 5.095328e+06 23.578448
1981-01-13 26.3418 26.3418 26.230000 26.2300 88494.00 0.0 0.86 0.387299 0.387299 0.385655 0.385655 4.955664e+06 22.653948
1981-01-14 26.3418 26.4450 26.341800 26.3418 54868.00 0.0 0.86 0.387299 0.388816 0.387299 0.387299 3.072608e+06 22.653948
1981-01-15 26.8750 27.0900 26.875000 26.8750 54008.00 0.0 0.86 0.395138 0.398299 0.395138 0.395138 3.024448e+06 23.112500
1981-01-16 26.7632 26.7632 26.660000 26.6600 51428.00 0.0 0.86 0.393494 0.393494 0.391977 0.391977 2.879968e+06 23.016352
1981-01-19 28.2682 28.3800 28.268200 28.2682 159616.00 0.0 0.86 0.415622 0.417266 0.415622 0.415622 8.938496e+06 24.310652
1981-01-20 27.5200 27.5200 27.416800 27.4168 115498.00 0.0 0.86 0.404621 0.404621 0.403104 0.403104 6.467888e+06 23.667200
1981-01-21 27.9500 28.1650 27.950000 27.9500 61060.00 0.0 0.86 0.410944 0.414105 0.410944 0.410944 3.419360e+06 24.037000
1981-01-22 28.2682 28.4918 28.268200 28.2682 136482.00 0.0 0.86 0.415622 0.418910 0.415622 0.415622 7.642992e+06 24.310652
1981-01-23 28.2682 28.3800 28.165000 28.1650 43086.00 0.0 0.86 0.415622 0.417266 0.414105 0.414105 2.412816e+06 24.310652
1981-01-26 27.8382 27.8382 27.735000 27.7350 94600.00 0.0 0.86 0.409300 0.409300 0.407783 0.407783 5.297600e+06 23.940852
... ... ... ... ... ... ... ... ... ... ... ... ... ...
2018-02-13 139.2770 141.6850 139.019000 141.3324 27610090.16 0.0 0.86 139.277000 141.685000 139.019000 141.332400 2.761009e+07 119.778220
2018-02-14 140.2187 144.0844 140.076800 143.9382 34115493.08 0.0 0.86 140.218700 144.084400 140.076800 143.938200 3.411549e+07 120.588082
2018-02-15 146.0194 148.8574 145.340000 148.7714 43524251.70 0.0 0.86 146.019400 148.857400 145.340000 148.771400 4.352425e+07 125.576684
2018-02-16 148.2296 150.3452 147.722200 148.2898 34089361.98 0.0 0.86 148.229600 150.345200 147.722200 148.289800 3.408936e+07 127.477456
2018-02-20 147.9630 149.8636 147.421200 147.7910 28836670.32 0.0 0.86 147.963000 149.863600 147.421200 147.791000 2.883667e+07 127.248180
2018-02-21 148.6338 149.7432 147.068600 147.1202 30816822.04 0.0 0.86 148.633800 149.743200 147.068600 147.120200 3.081682e+07 127.825068
2018-02-22 147.7480 149.5970 147.670600 148.4360 26233539.76 0.0 0.86 147.748000 149.597000 147.670600 148.436000 2.623354e+07 127.063280
2018-02-23 149.3562 151.0590 149.244400 150.9773 28663139.52 0.0 0.86 149.356200 151.059000 149.244400 150.977300 2.866314e+07 128.446332
2018-02-26 151.6610 154.2754 151.540600 153.9142 31722331.52 0.0 0.86 151.661000 154.275400 151.540600 153.914200 3.172233e+07 130.428460
2018-02-27 154.0260 155.2128 153.217600 153.4154 33269241.90 0.0 0.86 154.026000 155.212800 153.217600 153.415400 3.326924e+07 132.462360
2018-02-28 154.1636 155.3289 153.123000 153.1832 28899933.64 0.0 0.86 154.163600 155.328900 153.123000 153.183200 2.889993e+07 132.580696
2018-03-01 153.5444 154.6065 148.487600 150.5000 41969694.20 0.0 0.86 153.544400 154.606500 148.487600 150.500000 4.196969e+07 132.048184
2018-03-02 148.6080 151.6180 148.307000 151.5406 33070397.00 0.0 0.86 148.608000 151.618000 148.307000 151.540600 3.307040e+07 127.802880
2018-03-05 150.6806 152.8564 150.087200 152.0652 24425174.76 0.0 0.86 150.680600 152.856400 150.087200 152.065200 2.442517e+07 129.585316
2018-03-06 153.0026 153.2950 151.471800 151.9362 20458115.16 0.0 0.86 153.002600 153.295000 151.471800 151.936200 2.045812e+07 131.582236
2018-03-07 150.4484 151.2310 149.872200 150.5258 27264977.32 0.0 0.86 150.448400 151.231000 149.872200 150.525800 2.726498e+07 129.385624
2018-03-08 150.9128 152.3232 150.560200 152.1684 19920839.62 0.0 0.86 150.912800 152.323200 150.560200 152.168400 1.992084e+07 129.785008
2018-03-09 153.0456 154.8000 152.555400 154.7828 26991215.24 0.0 0.86 153.045600 154.800000 152.555400 154.782800 2.699122e+07 131.619216
2018-03-12 155.0494 156.8554 154.980600 156.2792 27567648.30 0.0 0.86 155.049400 156.855400 154.980600 156.279200 2.756765e+07 133.342484
2018-03-13 157.0274 157.8100 154.146400 154.7742 26804827.44 0.0 0.86 157.027400 157.810000 154.146400 154.774200 2.680483e+07 135.043564
2018-03-14 155.0752 155.2472 152.916600 153.4584 25004903.34 0.0 0.86 155.075200 155.247200 152.916600 153.458400 2.500490e+07 133.364672
2018-03-15 153.5100 155.0064 153.140286 153.6390 19422725.90 0.0 0.86 153.510000 155.006400 153.140286 153.639000 1.942273e+07 132.018600
2018-03-16 153.6390 154.0432 152.753200 153.0972 31679352.16 0.0 0.86 153.639000 154.043200 152.753200 153.097200 3.167935e+07 132.129540
2018-03-19 152.4952 152.6242 149.347600 150.7580 28212037.70 0.0 0.86 152.495200 152.624200 149.347600 150.758000 2.821204e+07 131.145872
2018-03-20 150.7064 152.0480 150.448400 150.7064 16610073.54 0.0 0.86 150.706400 152.048000 150.448400 150.706400 1.661007e+07 129.607504
2018-03-21 150.5344 150.5774 147.283600 147.2922 30312727.88 0.0 0.86 150.534400 150.577400 147.283600 147.292200 3.031273e+07 129.459584
2018-03-22 146.2000 148.5048 144.996000 145.2067 35303925.36 0.0 0.86 146.200000 148.504800 144.996000 145.206700 3.530393e+07 125.732000
2018-03-23 144.8154 146.1312 141.848400 141.8484 34614100.44 0.0 0.86 144.815400 146.131200 141.848400 141.848400 3.461410e+07 124.541244
2018-03-26 144.5402 148.8660 143.138400 148.5822 31194450.62 0.0 0.86 144.540200 148.866000 143.138400 148.582200 3.119445e+07 124.304572
2018-03-27 149.3648 150.6290 143.551200 144.7724 33508041.54 0.0 0.86 149.364800 150.629000 143.551200 144.772400 3.350804e+07 128.453728

9400 rows × 13 columns


In [118]:
def converter(data):
    return data*0.86

In [121]:
df.apply(converter)


Out[121]:
Open High Low Close Volume Ex-Dividend Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume New_Price
Date
1980-12-12 24.7250 24.8282 24.725000 24.7250 1800754.00 0.0 0.86 0.363527 0.365044 0.363527 0.363527 1.008422e+08 21.263500
1980-12-15 23.5468 23.5468 23.435000 23.4350 675272.00 0.0 0.86 0.346204 0.346204 0.344560 0.344560 3.781523e+07 20.250248
1980-12-16 21.8182 21.8182 21.715000 21.7150 405920.00 0.0 0.86 0.320789 0.320789 0.319272 0.319272 2.273152e+07 18.763652
1980-12-17 22.2482 22.3600 22.248200 22.2482 331874.00 0.0 0.86 0.327111 0.328755 0.327111 0.327111 1.858494e+07 19.133452
1980-12-18 22.9018 23.0050 22.901800 22.9018 281994.00 0.0 0.86 0.336721 0.338238 0.336721 0.336721 1.579166e+07 19.695548
1980-12-19 24.2950 24.4068 24.295000 24.2950 186706.00 0.0 0.86 0.357205 0.358849 0.357205 0.357205 1.045554e+07 20.893700
1980-12-22 25.4818 25.5850 25.481800 25.4818 143448.00 0.0 0.86 0.374654 0.376172 0.374654 0.374654 8.033088e+06 21.914348
1980-12-23 26.5568 26.6600 26.556800 26.5568 180256.00 0.0 0.86 0.390460 0.391977 0.390460 0.390460 1.009434e+07 22.838848
1980-12-24 27.9500 28.0618 27.950000 27.9500 184298.00 0.0 0.86 0.410944 0.412587 0.410944 0.410944 1.032069e+07 24.037000
1980-12-26 30.5300 30.6332 30.530000 30.5300 213366.00 0.0 0.86 0.448877 0.450394 0.448877 0.448877 1.194850e+07 26.255800
1980-12-29 30.9600 31.0718 30.960000 30.9600 357674.00 0.0 0.86 0.455199 0.456843 0.455199 0.455199 2.002974e+07 26.625600
1980-12-30 30.3150 30.3150 30.203200 30.2032 264450.00 0.0 0.86 0.445716 0.445716 0.444072 0.444072 1.480920e+07 26.070900
1980-12-31 29.4550 29.4550 29.351800 29.3518 137256.00 0.0 0.86 0.433071 0.433071 0.431554 0.431554 7.686336e+06 25.331300
1981-01-02 29.6700 29.8850 29.670000 29.6700 83162.00 0.0 0.86 0.436233 0.439394 0.436233 0.436233 4.657072e+06 25.516200
1981-01-05 29.1282 29.1282 29.025000 29.0250 137170.00 0.0 0.86 0.428267 0.428267 0.426749 0.426749 7.681520e+06 25.050252
1981-01-06 27.8382 27.8382 27.735000 27.7350 173376.00 0.0 0.86 0.409300 0.409300 0.407783 0.407783 9.709056e+06 23.940852
1981-01-07 26.6600 26.6600 26.556800 26.5568 213796.00 0.0 0.86 0.391977 0.391977 0.390460 0.390460 1.197258e+07 22.927600
1981-01-08 26.1182 26.1182 26.015000 26.0150 152908.00 0.0 0.86 0.384011 0.384011 0.382494 0.382494 8.562848e+06 22.461652
1981-01-09 27.4168 27.5200 27.416800 27.4168 82560.00 0.0 0.86 0.403104 0.404621 0.403104 0.403104 4.623360e+06 23.578448
1981-01-12 27.4168 27.4168 27.193200 27.1932 90988.00 0.0 0.86 0.403104 0.403104 0.399817 0.399817 5.095328e+06 23.578448
1981-01-13 26.3418 26.3418 26.230000 26.2300 88494.00 0.0 0.86 0.387299 0.387299 0.385655 0.385655 4.955664e+06 22.653948
1981-01-14 26.3418 26.4450 26.341800 26.3418 54868.00 0.0 0.86 0.387299 0.388816 0.387299 0.387299 3.072608e+06 22.653948
1981-01-15 26.8750 27.0900 26.875000 26.8750 54008.00 0.0 0.86 0.395138 0.398299 0.395138 0.395138 3.024448e+06 23.112500
1981-01-16 26.7632 26.7632 26.660000 26.6600 51428.00 0.0 0.86 0.393494 0.393494 0.391977 0.391977 2.879968e+06 23.016352
1981-01-19 28.2682 28.3800 28.268200 28.2682 159616.00 0.0 0.86 0.415622 0.417266 0.415622 0.415622 8.938496e+06 24.310652
1981-01-20 27.5200 27.5200 27.416800 27.4168 115498.00 0.0 0.86 0.404621 0.404621 0.403104 0.403104 6.467888e+06 23.667200
1981-01-21 27.9500 28.1650 27.950000 27.9500 61060.00 0.0 0.86 0.410944 0.414105 0.410944 0.410944 3.419360e+06 24.037000
1981-01-22 28.2682 28.4918 28.268200 28.2682 136482.00 0.0 0.86 0.415622 0.418910 0.415622 0.415622 7.642992e+06 24.310652
1981-01-23 28.2682 28.3800 28.165000 28.1650 43086.00 0.0 0.86 0.415622 0.417266 0.414105 0.414105 2.412816e+06 24.310652
1981-01-26 27.8382 27.8382 27.735000 27.7350 94600.00 0.0 0.86 0.409300 0.409300 0.407783 0.407783 5.297600e+06 23.940852
... ... ... ... ... ... ... ... ... ... ... ... ... ...
2018-02-13 139.2770 141.6850 139.019000 141.3324 27610090.16 0.0 0.86 139.277000 141.685000 139.019000 141.332400 2.761009e+07 119.778220
2018-02-14 140.2187 144.0844 140.076800 143.9382 34115493.08 0.0 0.86 140.218700 144.084400 140.076800 143.938200 3.411549e+07 120.588082
2018-02-15 146.0194 148.8574 145.340000 148.7714 43524251.70 0.0 0.86 146.019400 148.857400 145.340000 148.771400 4.352425e+07 125.576684
2018-02-16 148.2296 150.3452 147.722200 148.2898 34089361.98 0.0 0.86 148.229600 150.345200 147.722200 148.289800 3.408936e+07 127.477456
2018-02-20 147.9630 149.8636 147.421200 147.7910 28836670.32 0.0 0.86 147.963000 149.863600 147.421200 147.791000 2.883667e+07 127.248180
2018-02-21 148.6338 149.7432 147.068600 147.1202 30816822.04 0.0 0.86 148.633800 149.743200 147.068600 147.120200 3.081682e+07 127.825068
2018-02-22 147.7480 149.5970 147.670600 148.4360 26233539.76 0.0 0.86 147.748000 149.597000 147.670600 148.436000 2.623354e+07 127.063280
2018-02-23 149.3562 151.0590 149.244400 150.9773 28663139.52 0.0 0.86 149.356200 151.059000 149.244400 150.977300 2.866314e+07 128.446332
2018-02-26 151.6610 154.2754 151.540600 153.9142 31722331.52 0.0 0.86 151.661000 154.275400 151.540600 153.914200 3.172233e+07 130.428460
2018-02-27 154.0260 155.2128 153.217600 153.4154 33269241.90 0.0 0.86 154.026000 155.212800 153.217600 153.415400 3.326924e+07 132.462360
2018-02-28 154.1636 155.3289 153.123000 153.1832 28899933.64 0.0 0.86 154.163600 155.328900 153.123000 153.183200 2.889993e+07 132.580696
2018-03-01 153.5444 154.6065 148.487600 150.5000 41969694.20 0.0 0.86 153.544400 154.606500 148.487600 150.500000 4.196969e+07 132.048184
2018-03-02 148.6080 151.6180 148.307000 151.5406 33070397.00 0.0 0.86 148.608000 151.618000 148.307000 151.540600 3.307040e+07 127.802880
2018-03-05 150.6806 152.8564 150.087200 152.0652 24425174.76 0.0 0.86 150.680600 152.856400 150.087200 152.065200 2.442517e+07 129.585316
2018-03-06 153.0026 153.2950 151.471800 151.9362 20458115.16 0.0 0.86 153.002600 153.295000 151.471800 151.936200 2.045812e+07 131.582236
2018-03-07 150.4484 151.2310 149.872200 150.5258 27264977.32 0.0 0.86 150.448400 151.231000 149.872200 150.525800 2.726498e+07 129.385624
2018-03-08 150.9128 152.3232 150.560200 152.1684 19920839.62 0.0 0.86 150.912800 152.323200 150.560200 152.168400 1.992084e+07 129.785008
2018-03-09 153.0456 154.8000 152.555400 154.7828 26991215.24 0.0 0.86 153.045600 154.800000 152.555400 154.782800 2.699122e+07 131.619216
2018-03-12 155.0494 156.8554 154.980600 156.2792 27567648.30 0.0 0.86 155.049400 156.855400 154.980600 156.279200 2.756765e+07 133.342484
2018-03-13 157.0274 157.8100 154.146400 154.7742 26804827.44 0.0 0.86 157.027400 157.810000 154.146400 154.774200 2.680483e+07 135.043564
2018-03-14 155.0752 155.2472 152.916600 153.4584 25004903.34 0.0 0.86 155.075200 155.247200 152.916600 153.458400 2.500490e+07 133.364672
2018-03-15 153.5100 155.0064 153.140286 153.6390 19422725.90 0.0 0.86 153.510000 155.006400 153.140286 153.639000 1.942273e+07 132.018600
2018-03-16 153.6390 154.0432 152.753200 153.0972 31679352.16 0.0 0.86 153.639000 154.043200 152.753200 153.097200 3.167935e+07 132.129540
2018-03-19 152.4952 152.6242 149.347600 150.7580 28212037.70 0.0 0.86 152.495200 152.624200 149.347600 150.758000 2.821204e+07 131.145872
2018-03-20 150.7064 152.0480 150.448400 150.7064 16610073.54 0.0 0.86 150.706400 152.048000 150.448400 150.706400 1.661007e+07 129.607504
2018-03-21 150.5344 150.5774 147.283600 147.2922 30312727.88 0.0 0.86 150.534400 150.577400 147.283600 147.292200 3.031273e+07 129.459584
2018-03-22 146.2000 148.5048 144.996000 145.2067 35303925.36 0.0 0.86 146.200000 148.504800 144.996000 145.206700 3.530393e+07 125.732000
2018-03-23 144.8154 146.1312 141.848400 141.8484 34614100.44 0.0 0.86 144.815400 146.131200 141.848400 141.848400 3.461410e+07 124.541244
2018-03-26 144.5402 148.8660 143.138400 148.5822 31194450.62 0.0 0.86 144.540200 148.866000 143.138400 148.582200 3.119445e+07 124.304572
2018-03-27 149.3648 150.6290 143.551200 144.7724 33508041.54 0.0 0.86 149.364800 150.629000 143.551200 144.772400 3.350804e+07 128.453728

9400 rows × 13 columns


In [125]:
column_name = input("Pleae, input column name to print ")
print(df[column_name])


Pleae, input column name to print High
Date
1980-12-12     28.870
1980-12-15     27.380
1980-12-16     25.370
1980-12-17     26.000
1980-12-18     26.750
1980-12-19     28.380
1980-12-22     29.750
1980-12-23     31.000
1980-12-24     32.630
1980-12-26     35.620
1980-12-29     36.130
1980-12-30     35.250
1980-12-31     34.250
1981-01-02     34.750
1981-01-05     33.870
1981-01-06     32.370
1981-01-07     31.000
1981-01-08     30.370
1981-01-09     32.000
1981-01-12     31.880
1981-01-13     30.630
1981-01-14     30.750
1981-01-15     31.500
1981-01-16     31.120
1981-01-19     33.000
1981-01-20     32.000
1981-01-21     32.750
1981-01-22     33.130
1981-01-23     33.000
1981-01-26     32.370
               ...   
2018-02-13    164.750
2018-02-14    167.540
2018-02-15    173.090
2018-02-16    174.820
2018-02-20    174.260
2018-02-21    174.120
2018-02-22    173.950
2018-02-23    175.650
2018-02-26    179.390
2018-02-27    180.480
2018-02-28    180.615
2018-03-01    179.775
2018-03-02    176.300
2018-03-05    177.740
2018-03-06    178.250
2018-03-07    175.850
2018-03-08    177.120
2018-03-09    180.000
2018-03-12    182.390
2018-03-13    183.500
2018-03-14    180.520
2018-03-15    180.240
2018-03-16    179.120
2018-03-19    177.470
2018-03-20    176.800
2018-03-21    175.090
2018-03-22    172.680
2018-03-23    169.920
2018-03-26    173.100
2018-03-27    175.150
Name: High, Length: 9400, dtype: float64

In [154]:
my_string = " Please, input column, name to print. "

In [144]:
my_string.replace("Please","Quickly") #replaces old value with new


Out[144]:
'Quickly, input column name to print.'

In [147]:
my_string.strip() #strips down whitespace from the very begining the the very end


Out[147]:
'Please, input column name to print.'

In [152]:
my_string.lower().count("p") #count all p-s whether upper or not


Out[152]:
3

In [162]:
my_string.split(",")[0][1:]


Out[162]:
'Please'

In [164]:
my_string[0:my_string.find(",")]


Out[164]:
' Please'

In [180]:



100USD

In [175]:
splitted = money.split(" ")

In [178]:
print("The user inputed ",splitted[0],"in",splitted[-1])


The user inputed  100 in USD

In [177]:
splitted


Out[177]:
['100', '', '', '', '', '', 'USD']

In [ ]:
["1","0","0","U","S","D"]
[100]
["USD"]

In [182]:
list(money)


Out[182]:
['1', '0', '0', 'U', 'S', 'D']

In [187]:
list(money)[3].isdigit()


Out[187]:
False

In [189]:
#1) split the list
#2) Find intergers and join them
#3) join everying else

In [190]:


In [191]:
print(splitted)


['1', '0', '0', 'U', 'S', 'D']

In [199]:
money = input()
splitted = list(money)
digits = ""
letters = ""
for i in splitted:
    if i.isdigit()==True:
        digits = digits + i
    else:
        letters = letters + i
letters = letters.strip()
print("The user inputed ",digits,"in",letters)


100        AMD
The user inputed  100 in AMD

In [200]:
import this


The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

In [ ]: