Professional Documents
Culture Documents
Collections Datetime
Collections Datetime
In [1]:
In [2]:
l = [1, 2, 1, 3, 4, 1, 2, 5]
In [3]:
Counter(l)
Out[3]:
Counter({1: 3, 2: 2, 3: 1, 4: 1, 5: 1})
In [4]:
animales = "gato perro canario gato oveja jirafa perro canario jirafa jirafa ovejita
In [5]:
Counter(animales)
Out[5]:
Counter({'g': 2,
'a': 14,
't': 3,
'o': 8,
' ': 10,
'p': 2,
'e': 4,
'r': 9,
'c': 2,
'n': 2,
'i': 6,
'v': 2,
'j': 5,
'f': 3})
In [6]:
l1 = Counter(l)
l1.most_common(1)
Out[6]:
[(1, 3)]
https://hub.gke.mybinder.org/user/ipython-ipython-in-depth-sf3vkic3/notebooks/binder/Untitled.ipynb?kernel_name=python3 1/4
24/8/2019 Untitled
In [14]:
d = defaultdict(int)
d[1] = 1
d[2] = 4
d[3] = 3
d[0] = 1
d
Out[14]:
In [16]:
d = OrderedDict(d)
d
Out[16]:
In [27]:
import datetime
dt = datetime.datetime.now()
dt
Out[27]:
In [21]:
dt.year
Out[21]:
2019
In [22]:
dt.month
Out[22]:
In [23]:
dt.day
Out[23]:
24
https://hub.gke.mybinder.org/user/ipython-ipython-in-depth-sf3vkic3/notebooks/binder/Untitled.ipynb?kernel_name=python3 2/4
24/8/2019 Untitled
In [24]:
dt.hour
Out[24]:
In [28]:
dt.tzinfo
In [29]:
dt.strftime("%A %d %B %Y %I:%M")
Out[29]:
In [43]:
import locale
locale.setlocale(locale.LC_ALL, 'es_ES.UTF-8')
----------------------------------------------------------------------
-----
Error Traceback (most recent call
last)
<ipython-input-43-54b233d80e90> in <module>
1 import locale
----> 2 locale.setlocale(locale.LC_ALL, 'es_ES.UTF-8')
In [35]:
dt.strftime("%A %d %B %Y %I:%M")
Out[35]:
In [45]:
Out[45]:
https://hub.gke.mybinder.org/user/ipython-ipython-in-depth-sf3vkic3/notebooks/binder/Untitled.ipynb?kernel_name=python3 3/4
24/8/2019 Untitled
In [46]:
import pytz
In [47]:
pytz.all_timezones
Out[47]:
['Africa/Abidjan',
'Africa/Accra',
'Africa/Addis_Ababa',
'Africa/Algiers',
'Africa/Asmara',
'Africa/Asmera',
'Africa/Bamako',
'Africa/Bangui',
'Africa/Banjul',
'Africa/Bissau',
'Africa/Blantyre',
'Africa/Brazzaville',
'Africa/Bujumbura',
'Africa/Cairo',
'Africa/Casablanca',
'Africa/Ceuta',
'Africa/Conakry',
'Africa/Dakar',
In [48]:
dt = datetime.datetime.now(pytz.timezone('Europe/Madrid'))
In [49]:
dt
Out[49]:
In [ ]:
https://hub.gke.mybinder.org/user/ipython-ipython-in-depth-sf3vkic3/notebooks/binder/Untitled.ipynb?kernel_name=python3 4/4