I often want to loop through set of dates.
#Loop through a set of dates
#Import datetime and time functions
from datetime import datetime, timedelta
#Start Date
current_time = datetime(2015,01,01)
#Loop until a specified date is reached
while current_time < datetime(2015,01,30):
#Do whatever you want to after getting the date
string_time = current_time.strftime("%Y%m%d_%H%M")
print string_time
#add one minute and do the next date
current_time = current_time+timedelta(minutes=1)
This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock
Friday, January 9, 2015
Tuesday, January 6, 2015
Adding additional packages through Anaconda Command Prompt
If you downloaded Python from the Anaconda (I recommend this distribution service) then you can use the Anaconda Command Prompt to download additional packages. The ones I need are netcdf4, hdf5, basemap, and maybe some others will be useful later.
The available packages are found here: http://docs.continuum.io/anaconda/pkg-docs.html
Simply open the Anaconda Command Prompt:
Type conda install <name of package>
Below is an example of downloading the hdf5 packagae
You will then be prompted to answer whether or not you really want to install it. Type y
It will then fetch the package and install it.
The available packages are found here: http://docs.continuum.io/anaconda/pkg-docs.html
Simply open the Anaconda Command Prompt:
Type conda install <name of package>
Below is an example of downloading the hdf5 packagae
When the prompt comes up, type conda install hdf5
It will then fetch the package and install it.
Pretty easy. The hardest part is remembering what the names of what packages are available. Again, here is the link and a list of packages from Continuum's website:
Python version: 2.7
Number of supported packages: 224
Name | Version | License | In Installer |
abstract-rendering Linux Mac | 0.5.1 | 3rd-clause BSD | True |
apptools | 4.2.1 | BSD | False |
argcomplete | 0.8.1 | Apache Software License | True |
astroid | 1.2.1 | LGPL | False |
astropy | 0.4.2 | BSD | True |
atom | 0.3.9 | BSD | True |
basemap | 1.0.7 | PSF | False |
bcolz | 0.7.1 | BSD | False |
beautiful-soup | 4.3.2 | PSF/MIT | True |
binstar | 0.7.1 | BSD | True |
biopython | 1.64 | BSD-like | False |
bitarray | 0.8.1 | PSF | True |
blaze | 0.6.3 | BSD | True |
blist | 1.3.6 | BSD | False |
blz | 0.6.2 | BSD | True |
bokeh | 0.6.1 | New BSD | True |
boto | 2.32.1 | MIT | True |
bsddb Linux Mac | 1.0 | PSF | False |
bsdiff4 | 1.1.4 | BSD | False |
cairo Linux | 1.12.2 | LGPL 2.1 and MPL 1.1 | True |
casuarius | 1.1 | LGPL | True |
cdecimal | 2.3 | BSD | True |
cffi | 0.8.6 | MIT | True |
chaco | 4.4.1 | BSD | True |
chameleon | 2.16 | BSD-like | False |
cheetah | 2.4.4 | MIT | False |
chrpath Linux | 0.13 | GPL | False |
colorama | 0.3.1 | BSD | True |
conda | 3.7.0 | BSD | True |
conda-api | 1.1.0 | BSD | False |
conda-build | 1.8.2 | BSD | True |
configobj | 5.0.6 | BSD | True |
coverage | 3.7.1 | BSD | False |
cryptography | 0.5.4 | Apache 2.0 | True |
cssselect | 0.9.1 | BSD | False |
cubes | 0.10.2 | MIT | False |
curl Linux Mac | 7.38.0 | MIT/X derivate | True |
cython | 0.21 | Apache 2.0 | True |
cytoolz | 0.7.0 | BSD | True |
datashape | 0.3.0 | BSD | True |
dateutil | 2.1 | BSD | True |
db Linux Mac | 5.3.28 | AGPLv3 | False |
decorator | 3.4.0 | BSD | True |
django | 1.7 | BSD | False |
dnspython | 1.10.0 | as-is | False |
docutils | 0.12 | Public-Domain, PSF, 2-clause BSD, GPL3 | True |
dynd-python | 0.6.5 | BSD | True |
ecdsa | 0.11 | MIT | False |
enable | 4.3.0 | BSD | True |
enaml | 0.9.8 | BSD | True |
envisage | 4.4.0 | BSD | False |
ephem | 3.7.5.3 | LGPL | False |
faulthandler | 2.3 | BSD | False |
feedparser | 5.1.3 | MIT | False |
fiona | 1.1.6 | BSD | False |
flake8 | 2.2.3 | MIT | False |
flask | 0.10.1 | BSD | True |
freetype Linux Mac | 2.4.10 | FreeType License | True |
future | 0.13.1 | MIT | True |
futures | 2.1.6 | BSD | True |
gdal | 1.11.0 | MIT | False |
gdata | 2.0.18 | Apache 2.0 | False |
gensim | 0.10.2 | LGPL | False |
geos Linux Mac | 3.3.3 | LGPL | False |
gevent | 1.0.1 | MIT | True |
gevent-websocket | 0.9.3 | Apache | True |
googlecl | 0.9.12 | Apache 2.0 | False |
greenlet | 0.4.4 | MIT | True |
grin | 1.2.1 | BSD | True |
gunicorn Linux Mac | 19.1.0 | MIT | False |
h5py | 2.3.1 | New BSD | True |
hdf5 Linux Mac | 1.8.13 | BSD-style | True |
html5lib | 0.999 | MIT | False |
hyde Linux Mac | 0.8.5 | MIT | False |
iopro | 1.6.7 | proprietary - Continuum Analytics, Inc. | False |
ipython | 2.2.0 | BSD | True |
itsdangerous | 0.24 | BSD License | True |
jdcal | 1.0 | BSD | True |
jinja2 | 2.7.3 | BSD | True |
jpeg Linux Mac | 8d | Custom free software license | True |
kiwisolver | 0.1.3 | BSD | True |
launcher Mac Windows | 1.0.0 | proprietary - Continuum Analytics, Inc. | True |
lcms Linux Mac | 1.19 | MIT | True |
libdynd Linux Mac | 0.6.5 | BSD | True |
libffi Linux | 3.0.13 | MIT | True |
libnetcdf Linux Mac | 4.3.2 | MIT | False |
libpng Linux Mac | 1.5.13 | Open Source | True |
libsodium Linux Mac | 0.4.5 | MIT | True |
libtiff Linux Mac | 4.0.2 | as-is | True |
libxml2 Linux Mac | 2.9.0 | MIT | True |
libxslt Linux Mac | 1.1.28 | MIT | True |
llvm Linux Mac | 3.3 | Open Source | True |
llvmpy | 0.12.7 | New BSD License | True |
logilab-common | 0.62.1 | LGPL | False |
lxml | 3.4.0 | BSD | True |
markdown Linux Mac | 2.5 | BSD | False |
markupsafe | 0.23 | BSD | True |
mathjax | 2.2 | Apache | False |
matplotlib | 1.4.0 | PSF-based | True |
mayavi | 4.3.1 | BSD | False |
mccabe | 0.2.1 | Expat | False |
mdp | 3.3 | BSD | False |
menuinst Windows | 1.0.4 | BDF | True |
mercurial | 3.1 | GPLv2 | False |
mingw Windows | 4.7 | GPL | True |
mock | 1.0.1 | BSD | True |
mpi4py Linux | 1.3 | BSD | True |
mpich2 Linux | 1.4.1p1 | mpich license | True |
multimethods | 1.0.0 | MIT | False |
multipledispatch | 0.4.7 | BSD | True |
natsort | 3.5.0 | MIT | False |
netcdf4 | 1.1.1 | MIT | False |
networkx | 1.9.1 | BSD | True |
nltk | 3.0.0 | Apache 2.0 | True |
node-webkit Mac Windows | 0.10.1 | MIT | True |
nose | 1.3.4 | LGPL | True |
numba | 0.14.0 | numba license | True |
numexpr | 2.3.1 | MIT | True |
numpy | 1.9.0 | BSD | True |
numpydoc | 0.4 | BSD | False |
openpyxl | 1.8.5 | MIT/Expat | True |
openssl Linux Mac | 1.0.1h | Apache-style | True |
pandas | 0.14.1 | BSD | True |
pandasql | 0.6.1 | BSD | False |
paramiko | 1.14.1 | LGPL | False |
passlib | 1.6.2 | BSD | False |
pastedeploy Linux Mac | 1.5.2 | MIT | False |
patchelf Linux | 0.6 | GPL3 | False |
patsy | 0.3.0 | BSD License | True |
pep381client | 1.5 | Academic Free License, version 3 | False |
pep8 | 1.5.7 | MIT License | True |
pil | 1.1.7 | PIL license | True |
pillow Linux Mac | 2.5.1 | Standard PIL license | False |
pip | 1.5.6 | MIT | True |
pixman Linux | 0.26.2 | MIT | True |
ply | 3.4 | BSD | True |
psutil | 2.1.1 | BSD | True |
py | 1.4.25 | MIT | True |
py2cairo Linux | 1.10.0 | LGPL 2.1 and MPL 1.1 | True |
pyasn1 Linux | 0.1.6 | BSD | False |
pyaudio Mac | 0.2.7 | MIT | True |
pycosat | 0.6.1 | MIT | True |
pycparser | 2.10 | BSD | True |
pycrypto | 2.6.1 | Public Domain | True |
pycurl Linux Mac | 7.19.5 | LGPL and MIT/X | True |
pyface | 4.4.0 | BSD | True |
pyflakes | 0.8.1 | MIT | True |
pygments | 1.6 | BSD | True |
pylint | 1.3.1 | GPL | False |
pymc Linux | 2.3.3 | Academic Free License | False |
pymongo | 2.7.2 | Apache 2.0 | False |
pyodbc | 3.0.7 | MIT | False |
pyopenssl | 0.14 | APL2 | True |
pyparsing | 2.0.1 | MIT | True |
pyqt | 4.10.4 | GPL | True |
pyreadline Windows | 2.0 | BSD | True |
pysal | 1.6.0 | New BSD License | False |
pysam Linux Mac | 0.6 | MIT | False |
pyserial | 2.7 | PSF | False |
pytables | 3.1.1 | BSD | True |
pytest | 2.6.3 | MIT | True |
python | 2.7.8 | PSF | True |
pytz | 2014.7 | MIT | True |
pywin32 Windows | 219 | PSF | True |
pyyaml | 3.11 | MIT | True |
pyzmq | 14.3.1 | LGPL and BSD | True |
qt Linux Mac | 4.8.5 | LGPL | True |
queuelib | 1.2.2 | BSD | False |
readline Linux Mac | 6.2 | GPL 3 | True |
redis Linux Mac | 2.6.9 | 3-clause BSD | True |
redis-py Linux Mac | 2.9.1 | MIT | True |
reportlab | 3.1.8 | BSD | False |
repoze.lru | 0.6 | BSD | False |
requests | 2.4.1 | ISC | True |
rope | 0.9.4 | GPL | True |
runipy | 0.1.1 | BSD | True |
scikit-bio Linux Mac | 0.2.0 | BSD | False |
scikit-image | 0.10.1 | Modified BSD | True |
scikit-learn | 0.15.2 | 3-clause BSD | True |
scipy | 0.14.0 | BSD | True |
scrapy | 0.24.4 | BSD | False |
setuptools | 5.8 | PSF or ZPL | True |
shapely Linux Mac | 1.4.1 | BSD | False |
sip Linux Mac | 4.15.5 | GPL | True |
six | 1.8.0 | MIT | True |
sockjs-tornado | 1.0.1 | MIT | True |
sphinx | 1.2.3 | BSD | True |
spyder | 2.3.1 | MIT | True |
sqlalchemy | 0.9.7 | MIT | True |
sqlite Linux Mac | 3.8.4.1 | Public Domain | True |
sqlparse | 0.1.12 | BSD | False |
ssh | 1.8.0 | LGPL | False |
ssl_match_hostname | 3.4.0.2 | PSF | True |
starcluster Linux | 0.93.3 | LGPL | False |
statsmodels | 0.5.0 | 3-clause Modified BSD | True |
sympy | 0.7.5 | New BSD | True |
theano Linux | 0.6.0 | BSD | True |
tk Linux Mac | 8.5.15 | BSD-style | True |
toolz | 0.7.0 | BSD | True |
tornado | 4.0.2 | Apache | True |
traits | 4.4.0 | BSD | True |
traitsui | 4.4.0 | BSD | True |
twisted | 14.0.2 | MIT | False |
ujson | 1.33 | BSD | True |
unicodecsv | 0.9.4 | BSD | True |
unixodbc Linux | 2.3.1 | ??? | False |
util-linux Linux | 2.21 | GPL | True |
uuid | 1.30 | ??? | False |
venusian | 1.0 | BSD | False |
vtk | 5.10.1 | BSD | False |
w3lib | 1.8.1 | BSD | False |
werkzeug | 0.9.6 | BSD | True |
whoosh | 2.5.7 | BSD | False |
workerpool Linux | 0.9.2 | MIT | False |
xlrd | 0.9.3 | BSD | True |
xlsxwriter | 0.5.7 | BSD | True |
xlutils | 1.7.1 | MIT | False |
xlwings Windows | 0.2.2 | BSD 3-clause | True |
xlwt | 0.7.5 | BSD | True |
yaml Linux Mac | 0.1.4 | MIT | True |
yt Linux Mac | 3.0.1 | BSD | False |
zeromq Linux Mac | 4.0.4 | LGPL | True |
zlib Linux Mac | 1.2.7 | zlib | True |
zope.interface | 4.1.1 | Zope Public License | False |
Subscribe to:
Posts (Atom)