Reading and writing to an Excel ActiveX textbox with Python can be fun. If you really do not have anything better to do. Anyway, if this is your current task, you are on the correct place to see how it…
Python code examples
If you have ever dreamed that it will be possible to fill out an Excel cell with a picture, using Python, then you should probably reevaluate your dreams. Seriously, who dreams of something like that? Without further dreaming, the code…
Have you seen the error below?
1 2 3 4 5 6 |
Traceback (most recent call last): File "C:/Users/foo/PycharmProjects/pythonProject3/main.py", line 29, in <module> main() File "C:/Users/foo/PycharmProjects/pythonProject3/main.py", line 19, in main a['foo'] += 5 KeyError: 'foo' |
Of course you have. And you know, that it is because you have written something extremely unwise like this:
1 2 |
a = dict() a['foo'] += 5 |
Yeah. You cannot increment the value of a non-existent key. Unless… Unless you…
Intersection of dictionary (or of any two lists) is a list with elements, that are present in both other lists. Thus, if we have the following 3 dictionaries in Python:
1 2 3 |
dict_a = dict([('aa', 4139), ('bb', 4127), ('cc', 4098)]) dict_b = dict(aa=4139, bb=4127, ee=4098) dict_c = {'aa':12, 'bb':13, 'dd':23} |
Then, an intersection of their keys will contain only…
In the previous article for abstraction and inheritance I wrote some classes, showing the basics of these two programming concepts. In this one, I will write unit tests for one of the classes, written before. Software testing is an important…
In 2013 and 2014 (wow, already 7 years ago!) I wrote two articles about linear regression with Excel. Now, I am getting more and more interested in Python, thus I guess it would be interesting to remake the article into…
Working with python, pandas and dataframes is quite challenging even for experienced Excel & VBA developer, as I love to consider myself for one. Thus, today I was fighting for quite some time to add new columns to a dataframe,…
Python – Docstring – Help and Comments
Docstrings in Python are actually quite simple – the are 3 times this """ and the code between opening and closing them can be formatted in any possible way. The reason I have decided to dedicate a whole article to…