I need to look up a value within a table, find the value within in a string and return the first 3 digit zip of the string of zips - find

I need to lookup a zip-3 e.g.'825' within a table of grouped zips in a single column
787, 733
790, 791
793, 794, 792
802, 805, 800
806, 807
809, 816, 810, 814, 813, 811
820, 829, 826, 824, 822, 825, 827, 823, 828, 830, 831, 821, 834
837, 836, 833, 838, 834, 832, 835
840, 841, 847, 844, 843, 846, 845, 842
852, 853
857, 851
859, 855
860, 864, 865
I then need to be able to return the first value in that string i.e. I need to return '820'
I am working on two separate worksheets one with a list of zip-3's and another with grouped zip-3's so I need to be able to match the leading zip in a string to the individual zip-3 on my first worksheet.

Something like this should work:
=LEFT(INDEX('another with grouped zip-3''s'!A:A,MATCH("*"&Z1&"*",'another with grouped zip-3''s'!A:A,0)),3)

Related

How do I model serial correlation in a binomial model?

I'd like to test for trends in proportions of animals sampled over 12 years at six different beaches so that there is a separate trend test per beach. In the data below 'thisbeach' is the number of animals sampled at that particular beach and 'notthisbeach' is the number of animals sampled at all other beaches.
dat <- data.frame(fBeach = as.factor(rep(c("B6", "B5", "B2", "B1", "B4", "B3"), each=12)),
year = rep(seq(1:12),6),
notthisbeach = c(4990, 1294, 4346, 4082, 4628, 5576, 5939, 5664, 6108, 5195, 5564, 4079, 4694, 1224, 4052,
4019, 4457, 5242, 5259, 5198, 5971, 5208, 5168, 3722, 5499, 1288, 4202, 3988, 4773, 6018,
5952, 6100, 7308, 5821, 6030, 4546, 4698, 1300, 3884, 3943, 4717, 5911, 6110, 6076, 7606,
6138, 6514, 4767, 4830, 1307, 4886, 4327, 5285, 6344, 6627, 5824, 7305, 5991, 6073, 4647,
4584, 1162, 4200, 3956, 4710, 5664, 5533, 4828, 6082, 4697, 4721, 3529),
thisbeach = c(869, 221, 768, 781, 1086, 1375, 1145, 1074, 1968, 1415, 1250, 979, 1165, 291, 1062,
844, 1257, 1709, 1825, 1540, 2105, 1402, 1646, 1336, 360, 227, 912, 875, 941, 933,
1132, 638, 768, 789, 784, 512, 1161, 215, 1230, 920, 997, 1040, 974, 662, 470,
472, 300, 291, 1029, 208, 228, 536, 429, 607, 457, 914, 771, 619, 741, 411,
1275, 353, 914, 907, 1004, 1287, 1551, 1910, 1994, 1913, 2093, 1529))
glmmTMB indicates serial correlation is present;
require(glmmTMB)
require(DHARMa)
require(multcomp)
dat.TMB <- glmmTMB(cbind(notthisbeach,thisbeach) ~ year*fBeach, family = "betabinomial", data=dat)
simres <- simulateResiduals(dat.TMB,plot=T)
res = recalculateResiduals(simres, group = dat$year)
testTemporalAutocorrelation(res, time=unique(dat$year))
Durbin-Watson test
data: simulationOutput$scaledResiduals ~ 1
DW = 0.40903, p-value = 0.0002994
alternative hypothesis: true autocorrelation is not 0
However, I can't seem to find any examples including an autocorrelation structure in a model of this type.
Does anyone have any advice please?
I'm not sure I get the setup of the number of animals at this beach vs that beach, and depending on your research question you may need to do something different. However, basic patterns are easy enough to implement in glmmtmb. The example below shows an ar1.
dat <- data.frame(fBeach = as.factor(rep(c("B6", "B5", "B2", "B1", "B4", "B3"), each=12)),
year = rep(seq(1:12),6),
notthisbeach = c(4990, 1294, 4346, 4082, 4628, 5576, 5939, 5664, 6108, 5195, 5564, 4079, 4694, 1224, 4052,
4019, 4457, 5242, 5259, 5198, 5971, 5208, 5168, 3722, 5499, 1288, 4202, 3988, 4773, 6018,
5952, 6100, 7308, 5821, 6030, 4546, 4698, 1300, 3884, 3943, 4717, 5911, 6110, 6076, 7606,
6138, 6514, 4767, 4830, 1307, 4886, 4327, 5285, 6344, 6627, 5824, 7305, 5991, 6073, 4647,
4584, 1162, 4200, 3956, 4710, 5664, 5533, 4828, 6082, 4697, 4721, 3529),
thisbeach = c(869, 221, 768, 781, 1086, 1375, 1145, 1074, 1968, 1415, 1250, 979, 1165, 291, 1062,
844, 1257, 1709, 1825, 1540, 2105, 1402, 1646, 1336, 360, 227, 912, 875, 941, 933,
1132, 638, 768, 789, 784, 512, 1161, 215, 1230, 920, 997, 1040, 974, 662, 470,
472, 300, 291, 1029, 208, 228, 536, 429, 607, 457, 914, 771, 619, 741, 411,
1275, 353, 914, 907, 1004, 1287, 1551, 1910, 1994, 1913, 2093, 1529))
head(dat)
dim(dat)
require(glmmTMB)
require(DHARMa)
require(multcomp)
# function to test ar
testar <- function(mod, dat) {
simres <- simulateResiduals(mod,plot=T)
res <- recalculateResiduals(simres, group = dat$year)
print(testTemporalAutocorrelation(res, time=unique(dat$year)))
}
mod.TMB <- glmmTMB(cbind(notthisbeach,thisbeach) ~ year*fBeach, family = "betabinomial", data=dat)
testar(mod.TMB, dat)
# results
# Durbin-Watson test
#
# data: simulationOutput$scaledResiduals ~ 1
# DW = 0.40903, p-value = 0.0002994
# alternative hypothesis: true autocorrelation is not 0
mod.TMB.ar <- glmmTMB(cbind(notthisbeach,thisbeach) ~ as.factor(year) + fBeach + ar1(as.factor(year) + 0 | fBeach), family = "betabinomial", data=dat)
testar(mod.TMB.ar, dat)
#
# Durbin-Watson test
#
# data: simulationOutput$scaledResiduals ~ 1
# DW = 1.179, p-value = 0.1242
# alternative hypothesis: true autocorrelation is not 0
VarCorr(mod.TMB.ar)
# Conditional model:
# Groups Name Std.Dev. Corr
# fBeach as.factor(year)1 0.21692 0.464 (ar1)

I got error 255 , when i doing initial commit. Mercurial TortoiseHg

Good day. Tell me please, why i have error 255, when i doing initial commit, error on scr. When I commit in parts of 2-4 files, it works, and when all the files are completely, it gives an error.
src error 255
And on the other server everything is fine. Tell me what could be the problem?
Server data: Apache 2.4.41, PHP 7.4.3, MySQL Ver 8.0.22-0, NodeJS v15.8.0, Samba, ubuntu 20.04
Text of error
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
** Mercurial Distributed SCM (version 5.0.2)
** Extensions loaded: tortoisehg.util.hgcommands, tortoisehg.util.partialcommit, tortoisehg.util.pipeui, tortoisehg.util.win32ill, tortoisehg.util.hgdispatch
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
** Mercurial Distributed SCM (version 5.0.2)
** Extensions loaded: tortoisehg.util.hgcommands, tortoisehg.util.partialcommit, tortoisehg.util.pipeui, tortoisehg.util.win32ill, tortoisehg.util.hgdispatch
Traceback (most recent call last):
File "hg", line 50, in <module>
File "mercurial\dispatch.pyo", line 99, in run
File "mercurial\dispatch.pyo", line 225, in dispatch
File "mercurial\dispatch.pyo", line 376, in _runcatch
File "mercurial\dispatch.pyo", line 384, in _callcatch
File "mercurial\scmutil.pyo", line 167, in callcatch
File "mercurial\dispatch.pyo", line 367, in _runcatchfunc
File "mercurial\dispatch.pyo", line 1021, in _dispatch
File "mercurial\dispatch.pyo", line 756, in runcommand
File "mercurial\dispatch.pyo", line 1030, in _runcommand
File "mercurial\dispatch.pyo", line 1018, in <lambda>
File "mercurial\util.pyo", line 1680, in check
File "mercurial\commands.pyo", line 5300, in serve
File "mercurial\server.pyo", line 147, in runservice
File "mercurial\commandserver.pyo", line 405, in run
File "mercurial\commandserver.pyo", line 346, in serve
File "mercurial\commandserver.pyo", line 319, in serveone
File "mercurial\commandserver.pyo", line 303, in runcommand
File "mercurial\dispatch.pyo", line 225, in dispatch
File "mercurial\dispatch.pyo", line 376, in _runcatch
File "mercurial\dispatch.pyo", line 384, in _callcatch
File "mercurial\scmutil.pyo", line 167, in callcatch
File "mercurial\dispatch.pyo", line 367, in _runcatchfunc
File "tortoisehg\util\hgdispatch.pyo", line 23, in _dispatch
File "mercurial\dispatch.pyo", line 1021, in _dispatch
File "mercurial\dispatch.pyo", line 756, in runcommand
File "mercurial\dispatch.pyo", line 1030, in _runcommand
File "mercurial\dispatch.pyo", line 1018, in <lambda>
File "mercurial\util.pyo", line 1680, in check
File "mercurial\util.pyo", line 1680, in check
File "tortoisehg\util\partialcommit.pyo", line 34, in partialcommit
File "mercurial\util.pyo", line 1680, in check
File "mercurial\commands.pyo", line 1647, in commit
File "mercurial\commands.pyo", line 1722, in _docommit
File "mercurial\cmdutil.pyo", line 2434, in commit
File "mercurial\commands.pyo", line 1720, in commitfunc
File "mercurial\localrepo.pyo", line 177, in wrapper
File "mercurial\localrepo.pyo", line 2548, in commit
File "mercurial\localrepo.pyo", line 177, in wrapper
File "mercurial\localrepo.pyo", line 2622, in commitctx
File "mercurial\localrepo.pyo", line 2434, in _filecommit
File "mercurial\filelog.pyo", line 135, in add
File "mercurial\filelog.pyo", line 106, in addrevision
File "mercurial\revlog.pyo", line 1905, in addrevision
File "mercurial\revlog.pyo", line 1916, in addrawrevision
File "mercurial\revlog.pyo", line 544, in _indexfp
File "mercurial\store.pyo", line 571, in __call__
File "mercurial\vfs.pyo", line 420, in __call__
File "mercurial\util.pyo", line 2314, in makedirs
WindowsError: [Error 50] : '\\\\vsrvdev1\\web\\sez\\dev\\.hg/store\\data/~f4~fb~e2'
cmdserver: процесс завершился неожиданно с кодом 255
Don't store any repo in remote share, you'll have a lot of different headache with additional (not needed) networking layer.
All "Server data" is irrelevant to problem of Samba-shares

Issue when trying to install "pytest-allure-adaptor" in PyCharm

I am trying to generate XML allure reports through PyCharm on my pytest project. I have installed allure-pytest and required packages for the test cases to run. However when I try to install pytest-allure-adaptor from File -> Settings -> Project Interpreter I get the error as follows :
"error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/"
I have installed Visual C++ Redistributable for Visual Studio 2015 but it doesn't help. Please help me with a solution.
When I use pytest command to run my project I get the below error after install adaptor via pip install pytest-allure-adaptor :
Traceback (most recent call last):
File "c:\users\geeth\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\geeth\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\geeth\AppData\Local\Programs\Python\Python38\Scripts\pytest.exe\__main__.py", line 9, in <module>
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\config\__init__.py", line 105, in main
config = _prepareconfig(args, plugins)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\config\__init__.py", line 257, in _prepareconfig
return pluginmanager.hook.pytest_cmdline_parse(
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\helpconfig.py", line 90, in pytest_cmdline_parse
config = outcome.get_result()
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\config\__init__.py", line 836, in pytest_cmdline_parse
self.parse(args)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\config\__init__.py", line 1044, in parse
self._preparse(args, addopts=addopts)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\config\__init__.py", line 992, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\users\geeth\appdata\local\programs\python\python38\lib\importlib\metadata.py", line 77, in load
module = import_module(match.group('module'))
File "c:\users\geeth\appdata\local\programs\python\python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\assertion\rewrite.py", line 152, in exec_module
exec(co, module.__dict__)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure_pytest\plugin.py", line 3, in <module>
import allure
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\assertion\rewrite.py", line 152, in exec_module
exec(co, module.__dict__)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure\__init__.py", line 1, in <module>
from allure.pytest_plugin import MASTER_HELPER
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\assertion\rewrite.py", line 152, in exec_module
exec(co, module.__dict__)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure\pytest_plugin.py", line 9, in <module>
from allure.common import AllureImpl, StepContext
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\assertion\rewrite.py", line 152, in exec_module
exec(co, module.__dict__)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure\common.py", line 19, in <module>
from allure.structure import Attach, TestStep, TestCase, TestSuite, Failure, Environment, EnvParameter
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\_pytest\assertion\rewrite.py", line 152, in exec_module
exec(co, module.__dict__)
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure\structure.py", line 14, in <module>
class Attach(xmlfied('attachment',
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\allure\rules.py", line 116, in xmlfied
class MyImpl(namedlist('XMLFied', [(item[0], None) for item in items])):
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\namedlist.py", line 381, in namedlist
type_dict = {'__init__': _make_fn('__init__', _nl_init, fields, defaults),
File "c:\users\geeth\appdata\local\programs\python\python38\lib\site-packages\namedlist.py", line 180, in _make_fn
code = compile(module_node, '<string>', 'exec')
TypeError: required field "posonlyargs" missing from arguments

Upgraded Anaconda Ipython Packages and No Longer Able to Run NBConvert

PATH looks like this, what am I doing wrong? Pywin32 and Pandoc are already installed using Windows MSI:
C:\Users\AliDesktop\Anaconda;C:\Users\AliDesktop\Anaconda\Scripts;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\Graphviz2.38\bin\;C:\Users\AliDesktop\AppData\Local\Pandoc\
I get this on trying to run a command I usually run:
ipython nbconvert --to latex --post PDF .ipynb
C:\Users\AliDesktop\Desktop\Magic Briefcase\School\1\1- Intro to Data Science\le
cture\Summaries\IPython Notebooks>ipython nbconvert --to latex --post PDF .ipynb
Below is my error traceback:
Traceback (most recent call last):
File "C:\Users\AliDesktop\Anaconda\lib\runpy.py", line 162, in _run_module_as_
main
"__main__", fname, loader, pkg_name)
File "C:\Users\AliDesktop\Anaconda\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\AliDesktop\Anaconda\Scripts\ipython.exe\__main__.py", line 9, i
n <module>
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\__init__.py", lin
e 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 573, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\terminal\ipapp.py
", line 321, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\core\application.
py", line 369, in initialize
self.parse_command_line(argv)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\terminal\ipapp.py
", line 316, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 471, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 409, in initialize_subcommand
self.subapp.initialize(argv)
File "<string>", line 2, in initialize
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\nbconvert\nbconve
rtapp.py", line 211, in initialize
super(NbConvertApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\core\application.
py", line 369, in initialize
self.parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 495, in parse_command_line
self.update_config(config)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 394, in update_config
self.config = newconfig
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\utils\traitlets.p
y", line 445, in __set__
obj._notify_trait(self.name, old_value, new_value)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\utils\traitlets.p
y", line 602, in _notify_trait
c(name, old_value, new_value)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\applicatio
n.py", line 241, in _config_changed
SingletonConfigurable._config_changed(self, name, old, new)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\configurab
le.py", line 159, in _config_changed
self._load_config(new, traits=traits, section_names=section_names)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\config\configurab
le.py", line 143, in _load_config
setattr(self, name, deepcopy(config_value))
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\utils\traitlets.p
y", line 445, in __set__
obj._notify_trait(self.name, old_value, new_value)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\utils\traitlets.p
y", line 602, in _notify_trait
c(name, old_value, new_value)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\nbconvert\nbconve
rtapp.py", line 193, in _postprocessor_class_changed
self.postprocessor_factory = import_item(new)
File "C:\Users\AliDesktop\Anaconda\lib\site-packages\IPython\utils\importstrin
g.py", line 50, in import_item
return __import__(parts[0])
ImportError: No module named PDF
The options --to latex --post PDF have been replaced by --to pdf in IPython >= 3.0. So this should work:
ipython nbconvert --to pdf </path/to/notebook>
For further information see also issue #7973 on github.

Matplotlib: Formatting date in day.month.year style

I want to plot some lines with the date on the x axis, but all examples I could find use the American style like 12-31-2012. But I want 31.12.2012, but it doesn't seem to work by just changing the date formatter from
dateFormatter = dates.DateFormatter('%Y-%m-%d')
to
dateFormatter = dates.DateFormatter('%d.%m.%y')
My date list works like this: I want to define a "firstDay" manually, and then generate X succeeding days. That works as I can see when I print that result list.
But when I want to plot that list (converted by num2date) I have totally different dates.
E.g. I set my firstDay to 734517.0 which is January the 15th in 2012. Then I print my dates on the axis and I get as a first date 01.01.87 ??
Here is my full code:
import numpy as np
import matplotlib.pyplot as plot
import matplotlib.ticker as mticker
from matplotlib import dates
import datetime
fig = plot.figure(1)
DAU = ( 2, 20, 25, 60, 190, 210, 18, 196, 212, 200, 160, 150, 185, 175, 316, 320, 294, 260, 180, 145, 135, 97, 84, 80, 60, 45, 37, 20, 20, 24, 39, 73, 99)
WAU = ( 50, 160, 412, 403, 308, 379, 345, 299, 258, 367, 319, 381, 461, 412, 470, 470, 468, 380, 290, 268, 300, 312, 360, 350, 316, 307, 289, 321, 360, 378, 344, 340, 346)
MAU = (760, 620, 487, 751, 612, 601, 546, 409, 457, 518, 534, 576, 599, 637, 670, 686, 574, 568, 816, 578, 615, 520, 499, 503, 529, 571, 461, 614, 685, 702, 687, 649, 489)
firstDay = 734517.0 #15. Januar 2012
#create an array with len(DAU) entries from given starting day...
dayArray = []
for i in xrange(len(DAU)):
dayArray.append(firstDay + i)
#...and fill them with the converted dates
dayLabels = [dates.num2date(dayArray[j]) for j in xrange(len(DAU))]
for k in xrange(len(DAU)):
print dayLabels[k]
spacing = np.arange(len(DAU)) + 1
line1 = plot.plot(spacing, DAU, 'o-', color = '#336699')
line2 = plot.plot(spacing, WAU, 'o-', color = '#993333')
line3 = plot.plot(spacing, MAU, 'o-', color = '#89a54e')
ax = plot.subplot(111)
plot.ylabel('', weight = 'bold')
plot.title('', weight = 'bold')
ticks, labels = plot.xticks(spacing, dayLabels)
plot.setp(labels, rotation = 90, fontsize = 11)
dateFormatter = dates.DateFormatter('%d.%m.%y')
ax.xaxis.set_major_formatter(dateFormatter)
#ax.fmt_xdata = dates.DateFormatter('%Y-%m-%d')
#fig.autofmt_xdate()
yMax = max(np.max(DAU), np.max(WAU), np.max(MAU))
yLimit = 100 - (yMax % 100) + yMax
plot.yticks(np.arange(0, yLimit + 1, 100))
plot.grid(True, axis = 'y')
plot.subplots_adjust(bottom = 0.5)
plot.subplots_adjust(right = 0.82)
legend = plot.legend((line1[0], line2[0], line3[0]),
('DAU',
'WAU',
'MAU'),
'upper left',
bbox_to_anchor = [1, 1],
shadow = True)
frame = legend.get_frame()
frame.set_facecolor('0.80')
for t in legend.get_texts():
t.set_fontsize('small')
plot.show()
It would be fine as well with this date formatter:
ax.fmt_xdata = dates.DateFormatter('%Y-%m-%d')
but that gives me the timestamps as well, e.g. 2012-01-15 00:00:00+00:00 .
If someone could tell me how to cut the time off, it would be really great!!
It seems to me that the easiest way is to use real Datetime objects. This way you can use the datetime.timedelta(days=i) to make your date range. And matplotlib automatically takes spacing into account in case your dates are not regular. It also allows you to use the default date formatting options from matplotlib.
I left some code out to keep it simpler but you should be able to mix this with your script:
![import numpy as np
import matplotlib.pyplot as plot
import matplotlib.ticker as mticker
from matplotlib import dates
import datetime
fig = plot.figure(1)
DAU = ( 2, 20, 25, 60, 190, 210, 18, 196, 212, 200, 160, 150, 185, 175, 316, 320, 294, 260, 180, 145, 135, 97, 84, 80, 60, 45, 37, 20, 20, 24, 39, 73, 99)
WAU = ( 50, 160, 412, 403, 308, 379, 345, 299, 258, 367, 319, 381, 461, 412, 470, 470, 468, 380, 290, 268, 300, 312, 360, 350, 316, 307, 289, 321, 360, 378, 344, 340, 346)
MAU = (760, 620, 487, 751, 612, 601, 546, 409, 457, 518, 534, 576, 599, 637, 670, 686, 574, 568, 816, 578, 615, 520, 499, 503, 529, 571, 461, 614, 685, 702, 687, 649, 489)
firstDay = datetime.datetime(2012,1,15) #15. Januar 2012
dayArray = [firstDay + datetime.timedelta(days=i) for i in xrange(len(DAU))]
ax = plot.subplot(111)
line1 = ax.plot(dayArray, DAU, 'o-', color = '#336699')
line2 = ax.plot(dayArray, WAU, 'o-', color = '#993333')
line3 = ax.plot(dayArray, MAU, 'o-', color = '#89a54e')
ax.xaxis.set_major_formatter(dates.DateFormatter('%d.%m.%Y'))]
The main difference with your script is the way dayArray is created (and used as the x-value in the plotting command) and the last line which sets the format of the x-axis.