How to make div same height as parent (displayed as table-cell)

Another option is to set your child div to display: inline-block; .content { display: inline-block; height: 100%; width: 100%; background-color: blue; } .container { display: table; } .child { width: 30px; background-color: red; display: table-cell; vertical-align: top; } .content { display: inline-block; height: 100%; width: 100%; background-color: blue; } <div class=”container”> <div class=”child”> a <br … Read more

Set the variable result, from query

There are multiple ways to do this. You can use a sub query: SET @some_var = (SELECT COUNT(*) FROM mytable); (like your original, just add parenthesis around the query) or use the SELECT INTO syntax to assign multiple values: SELECT COUNT(*), MAX(col) INTO @some_var, @some_other_var FROM tab; The sub query syntax is slightly faster (I … Read more

Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead

You’re binding the ItemsSource to a property in the DataContext called Items, so to update the collection, you need to go to the Items property in the DataContext and clear it. In addition, the Items property needs to be of type ObservableCollection, not List if you want it to update the UI whenever the underlying … Read more

Creating a new column in Panda by using lambda function on two existing columns

You can use function map and select by function np.where more info print df # a b #0 aaa rrrr #1 bb k #2 ccc e #condition if condition is True then len column a else column b df[‘c’] = np.where(df[‘a’].map(len) > df[‘b’].map(len), df[‘a’].map(len), df[‘b’].map(len)) print df # a b c #0 aaa rrrr 4 … Read more

How to drop columns which have same values in all rows via pandas or spark dataframe?

What we can do is use nunique to calculate the number of unique values in each column of the dataframe, and drop the columns which only have a single unique value: In [285]: nunique = df.nunique() cols_to_drop = nunique[nunique == 1].index df.drop(cols_to_drop, axis=1) Out[285]: index id name data1 0 0 345 name1 3 1 1 … Read more

Python Pandas: drop a column from a multi-level column index?

With a multi-index we have to specify the column using a tuple in order to drop a specific column, or specify the level to drop all columns with that key on that index level. Instead of saying drop column ‘c’ say drop (‘a’,’c’) as shown below: df.drop((‘a’, ‘c’), axis = 1, inplace = True) Or … Read more