Skip to content

Commit 2e0c236

Browse files
author
BB
committed
-
1 parent 7a5dea6 commit 2e0c236

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

sk/2016/01/python-ile-finans-verileri.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ end=datetime.datetime(2015, 9, 30)
1919
s = web.DataReader("MSFT", 'yahoo', start, end)
2020
```
2121

22-
Kaynak icin `google` gecilirse veri oradan gelecek.
22+
Kaynak icin `google` gecilirse veri oradan gelecek.
23+
24+
Ayni sekilde 'fred' ABD merkez bankasi tabanindan veri indirebiliyor.
2325

2426
Opsiyon
2527

sk/2016/06/datetime.md

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,142 @@
11
# Tarih Zaman Icin datetime
22

3-
4-
Tarih Zaman Icin datetime
5-
6-
7-
8-
93
Python ile bazi datetime numaralari.
104

115
Bugunun tarihi
126

7+
```
138
import datetime
149
1510
print (datetime.datetime.now())
11+
```
1612

17-
Class datetime uzerinde bir suru ek bilgi vardir, mesela sadece bugunun ayini almak icin
13+
Class datetime uzerinde bir suru ek bilgi vardir, mesela sadece
14+
bugunun ayini almak icin
1815

16+
```
1917
print (datetime.datetime.now().month)
18+
```
2019

2120
Diger ogeler day, ya da year olabilir.
2221

2322
Bir dosyanin yaratilis tarihi icin (ve o tarihin gunu icin)
2423

24+
```
2525
print (datetime.datetime.fromtimestamp(os.path.getctime("[DOSYA]")).day)
26+
```
2627

27-
Java'dan gelen currentTimeInMillis() cagrisini normal tarihe donusturmek icin
28+
Java'dan gelen `currentTimeInMillis()` cagrisini normal tarihe
29+
donusturmek icin
2830

31+
```
2932
millis = 1492161538887
3033
from datetime import date
3134
print date.fromtimestamp(millis/1000.0)
35+
```
3236

3337
Sonuc
3438

39+
```
3540
2017-04-14
41+
```
3642

3743
String verisi ile tarih yaratmak,
3844

45+
```
3946
import datetime
4047
s = "10/10/11"
4148
d = datetime.datetime.strptime(s, "%m/%d/%y")
4249
print d
50+
```
4351

52+
```
4453
2011-10-10 00:00:00
54+
```
4555

4656
Gun eklemek (ya da cikartmak)
4757

58+
```
4859
print d + datetime.timedelta(days=10)
60+
```
4961

62+
```
5063
2011-10-20 00:00:00
64+
```
5165

5266
Tekrar string'e cevirmek
5367

68+
```
5469
print d.strftime('%Y-%m-%d')
70+
```
5571

72+
```
5673
2011-10-10
74+
```
5775

5876
Ayri ayri yil, gun, vs vererek yaratmak,
5977

78+
```
6079
d2 = datetime.datetime(1999, 1, 1)
6180
print d2
81+
```
6282

83+
```
6384
1999-01-01 00:00:00
85+
```
6486

65-
Bit tarih objesinin yil, gun, ay ogelerine bakmak,
87+
Bir tarih objesinin yil, gun, ay ogelerine bakmak,
6688

89+
```
6790
print d2.year, d2.month, d2.day
91+
```
6892

93+
```
6994
1999 1 1
95+
```
7096

7197
Zaman Farklari
7298

7399
Iki tarih arasindaki zaman farkini bulmak icin basit cikartma islemi yeterl
74100

101+
```
75102
d1 = datetime.datetime(1994, 1, 1)
76103
d2 = datetime.datetime(1999, 1, 1)
77104
78105
print d2-d1, type(d2-d1)
106+
```
79107

80108
Sonuc
81109

110+
```
82111
1826 days, 0:00:00
112+
```
83113

84114
Bu bir timedelta objesinden geliyor, bu objenin gecen zamani saniye olarak gosterme ozelligi de var
85115

116+
```
86117
print (d2-d1).total_seconds()
118+
```
87119

120+
```
88121
157766400.0
122+
```
89123

90124
Arrow, Pandas
91125

92-
Hem arrow hem pandas paketleri datetime işlenmesini destekliyor. Her iki paket ile herhangi bir formattaki zamanı alıp çevirebiliriz.
126+
Hem arrow hem pandas paketleri datetime işlenmesini destekliyor. Her
127+
iki paket ile herhangi bir formattaki zamanı alıp çevirebiliriz.
93128

129+
```
94130
import arrow
95131
96-
97132
arrow.get("2017-01-12T14:12:06.000")
133+
```
98134

99135
Fakat üstteki yavaş olabilir,
100136

137+
```
101138
import pandas as pd
102139
103140
arrow.get(pd.Timestamp("2017-01-12T14:12:06.000"))
104-
105-
106-
107-
141+
```
108142

0 commit comments

Comments
 (0)