How to apply a function to two columns of Pandas dataframe
Suppose I have a `df` which has columns of `'ID', 'col_1', 'col_2'`. And I define a function : `f = lambda x, y : my_function_expression`. Now I want to apply the `f` to `df`'s two columns `'col_1',...
How to check Django version
I have to use [Python](http://en.wikipedia.org/wiki/Python_%28programming_language%29) and [Django](http://en.wikipedia.org/wiki/Django_%28web_framework%29) for our application. So I have two versions...
Ternary operator (?:) in Bash
Is there a way to do something like this ``` int a = (b == 5) ? c : d; ``` using Bash?
- Modified
- 1 Sep at 19:10
What is the difference between UTF-8 and Unicode?
I have heard conflicting opinions from people - according to the [Wikipedia UTF-8](http://en.wikipedia.org/wiki/UTF-8) page. They are the same thing, aren't they? Can someone clarify?
- Modified
- 6 Jul at 11:54
sudo echo "something" >> /etc/privilegedFile doesn't work
This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux. There are a lot of times when I just want to append something to `/etc/hosts` or a similar file...
- Modified
- 6 Mar at 01:57
How do I bind to list of checkbox values with AngularJS?
I have a few checkboxes: ``` <input type='checkbox' value="apple" checked> <input type='checkbox' value="orange"> <input type='checkbox' value="pear" checked> <input type='checkbox' value="naartjie">...
- Modified
- 7 Jan at 15:16
How to convert a factor to integer\numeric without loss of information?
When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers. ``` f <- factor(sample(runif(5), 20, replace = TRUE)) ## [1] 0.0248644019011408 0.024864...
How to make an ImageView with rounded corners?
In Android, an ImageView is a rectangle by default. How can I make it a rounded rectangle (clip off all 4 corners of my Bitmap to be rounded rectangles) in the ImageView? --- Note that from 2021 on...
- Modified
- 18 Jun at 18:55
Node.js on multi-core machines
[Node.js](http://en.wikipedia.org/wiki/Node.js) looks interesting, I must miss something - isn't Node.js tuned only to run on a single process and thread? Then how does it scale for multi-core CPUs ...
- Modified
- 11 Jan at 12:3
Does Python have an ordered set?
Python has an [ordered dictionary](http://www.python.org/dev/peps/pep-0372/). What about an ordered set?
How do I merge my local uncommitted changes into another Git branch?
How can I do the following in Git? My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a wa...
Dialog throwing "Unable to add window — token null is not for an application” with getApplication() as context
My Activity is trying to create an AlertDialog which requires a Context as a parameter. This works as expected if I use: ``` AlertDialog.Builder builder = new AlertDialog.Builder(this); ``` However...
- Modified
- 23 May at 10:31
Why catch and rethrow an exception in C#?
I'm looking at the article [C# - Data Transfer Object](http://www.codeproject.com/KB/cs/datatransferobject.aspx) on serializable DTOs. The article includes this piece of code: ``` public static stri...
C# difference between == and Equals()
I have a condition in a silverlight application that compares 2 strings, for some reason when I use `==` it returns while `.Equals()` returns . Here is the code: ``` if (((ListBoxItem)lstBaseMenu.S...
How do I replace all line breaks in a string with <br /> elements?
How can I read the line break from a value with JavaScript and replace all the line breaks with `<br />` elements? Example: A variable passed from PHP as below: ``` "This is man. Man like dog...
- Modified
- 23 Mar at 19:47
In MVC, how do I return a string result?
In my AJAX call, I want to return a string value back to the calling page. Should I use `ActionResult` or just return a string?
- Modified
- 3 Oct at 21:57
What's the PostgreSQL datatype equivalent to MySQL AUTO INCREMENT?
I'm switching from MySQL to PostgreSQL and I was wondering how can I have an `INT` column with `AUTO INCREMENT`. I saw in the PostgreSQL docs a datatype called `SERIAL`, but I get syntax errors when u...
- Modified
- 25 Jun at 22:15
How can I force clients to refresh JavaScript files?
We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. Th...
- Modified
- 3 Aug at 19:4
How to properly assert that an exception gets raised in pytest?
## Code: ``` # coding=utf-8 import pytest def whatever(): return 9/0 def test_whatever(): try: whatever() except ZeroDivisionError as exc: pytest.fail(exc, pytrace=T...
- Modified
- 14 Feb at 14:6
How do I get the color from a hexadecimal color code using .NET?
How can I get a color from a hexadecimal color code (e.g. `#FFDFD991`)? I am reading a file and am getting a hexadecimal color code. I need to create the corresponding `System.Windows.Media.Color` in...
Query-string encoding of a JavaScript object
Is there a fast and simple way to encode a JavaScript object into a `string` that I can pass via a [GET](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods) request? No [jQuery]...
- Modified
- 27 Nov at 22:34
javascript pushing element at the beginning of an array
I have an array of objects and I'd like to push an element at the beginning of the of the array. I have this: ``` var TheArray = TheObjects.Array; TheArray.push(TheNewObject); ``` It's adding `TheNew...
- Modified
- 19 May at 08:8
Get checkbox value in jQuery
How can I get a checkbox's value in jQuery?
Why are #ifndef and #define used in C++ header files?
I have been seeing code like this usually in the start of header files: ``` #ifndef HEADERFILE_H #define HEADERFILE_H ``` And at the end of the file is ``` #endif ``` What is the purpose of this...
- Modified
- 25 Jul at 01:41
What's the difference between passing by reference vs. passing by value?
What is the difference between 1. a parameter passed by reference 2. a parameter passed by value? Could you give me some examples, please?
- Modified
- 19 Jul at 17:28