Regex difference: (\w+)? and (\w*)

(\w+)? and (\w*) both match the same (0..+inf word characters) However, there is a slight difference: In the first case, if this part of the regex matches “”, the capturing group is absent. In the second case, it is empty. In some languages, the former manifests as a null while the latter should always be … Read more

How to calculate time difference by group using pandas?

You can use sort_values with groupby and aggregating diff: df[‘diff’] = df.sort_values([‘id’,’time’]).groupby(‘id’)[‘time’].diff() print (df) id time diff 0 A 2016-11-25 16:32:17 NaT 1 A 2016-11-25 16:36:04 00:00:35 2 A 2016-11-25 16:35:29 00:03:12 3 B 2016-11-25 16:35:24 NaT 4 B 2016-11-25 16:35:46 00:00:22 If need remove rows with NaT in column diff use dropna: df = … Read more

How do I get PyCharm to show entire error diffs from pytest?

If you look closely into PyCharm sources, from the whole pytest output, PyCharm uses a single line the to parse the data for displaying in the Click to see difference dialog. This is the AssertionError: <message> line: def test_spam(): > assert v1 == v2 E AssertionError: assert {‘foo’: ‘bar’} == {‘foo’: ‘baz’} E Differing items: … Read more

css difference between background: and background-image:

In a background property you can add background-color, repeat, no-repeat and other image attributes, but in the background-image property you are only allowed to add image. background-image: url(“img_tree.png”); background-repeat: no-repeat; background-position: right top; background-attachment: fixed; and in background property you can do in one line all these background: #ccc url(paper.gif) no-repeat;

Differences between ComboBox and ChoiceBox in JavaFX

ComboBox supports a cellFactory which allows essentially an arbitrary UI for displaying the item in each cell. ChoiceBox does not have this functionality and will only display text in each cell (which you can configure using a converter). See http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/combo-box.htm#BABJCCIB listing 16.5 for an example of a custom cell factory in a combo box.

Get time difference between datetimes

This approach will work ONLY when the total duration is less than 24 hours: var now = “04/09/2013 15:00:00”; var then = “04/09/2013 14:20:30″; moment.utc(moment(now,”DD/MM/YYYY HH:mm:ss”).diff(moment(then,”DD/MM/YYYY HH:mm:ss”))).format(“HH:mm:ss”) // outputs: “00:39:30” If you have 24 hours or more, the hours will reset to zero with the above approach, so it is not ideal. If you want … Read more

Difference between np.dot and np.multiply with np.sum in binary cross-entropy loss calculation

np.dot is the dot product of two matrices. |A B| . |E F| = |A*E+B*G A*F+B*H| |C D| |G H| |C*E+D*G C*F+D*H| Whereas np.multiply does an element-wise multiplication of two matrices. |A B| ⊙ |E F| = |A*E B*F| |C D| |G H| |C*G D*H| When used with np.sum, the result being equal is merely … Read more

What is the Difference Between x:Key, x:Name, and x:UID in a DataTemplate in WPF?

The ‘x:’ specifies the namespace, which would in your case most likely be “http://schemas.microsoft.com/winfx/2006/xaml” You will see the alias declared at the top of your Window.Xaml file. x:Key, x:Name, etc are all directives in that namespace. In contrast, the ‘Name’ attribute (without the x:) is a dependency property declared in the FrameworkElement class. x:Key Uniquely … Read more