Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

Think of it like you're just calling JavaScript functions. You can't use a **for** loop where the arguments to a function call would go:
***return tbody(
for (var i = 0; i < numrows; i++) {
ObjectRow()
}
)***
See how the function **tbody** is being passed a **for** loop as an argument – leading to a syntax error.
But you can make an array, and then pass that in as an argument:
***var rows = [];
for (var i = 0; i < numrows; i++) {
rows.push(ObjectRow());
}
return tbody(rows);
***
You can basically use the same structure when working with JSX:
***var rows = [];
for (var i = 0; i < numrows; i++) {
// note: we are adding a key prop here to allow react to uniquely identify each
// element in this array.
rows.push();
}
return {rows};
***
Incidentally, my JavaScript example is almost exactly what that example of JSX transforms into. Play around with **Babel REPL** to get a feel for how JSX works.
4 years ago
**...** are called spread attributes which, as the name represents, it allows an expression to be expanded.

***var parts = ['two', 'three'];
var numbers = ['one', ...parts, 'four', 'five']; // ["one", "two", "three", "four", "five"]
***

And in this case (I'm going to simplify it).

***// Just assume we have an object like this:
var person= {
name: 'Alex',
age: 35
}
***
This:

******
is equal to

******
So in short, it's a **neat** short-cut, we can say.
4 years ago
**ReactJS** is a JavaScript library, supporting both front-end web and being run on a server, for building user interfaces and web applications. It follows the concept of reusable components.

**React Native** is a mobile framework that makes use of the JavaScript engine available on the host, allowing you to build mobile applications for different platforms (iOS, Android, and Windows Mobile) in JavaScript that allows you to use ReactJS to build reusable components and communicate with native components further explanation

Both follow the JSX syntax extension of JavaScript. Which compiles to **React.createElement** calls under the hood. **JSX in-depth**

Both are open-sourced by Facebook.
4 years ago
**setup.py** is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules.
This allows you to easily install Python packages. Often it's enough to write:
***$ pip install*** .
**pip** will use **setup.py** to install your module. Avoid calling **setup.py** directly.
4 years ago
You can try this:
***a = [['a', '1.2', '4.2'], ['b', '70', '0.03'], ['x', '5', '0']]
df = pd.DataFrame(a, columns=['one', 'two', 'three'])
df
Out[16]:
one two three
0 a 1.2 4.2
1 b 70 0.03
2 x 5 0

df.dtypes
Out[17]:
one object
two object
three object

df[['two', 'three']] = df[['two', 'three']].astype(float)

df.dtypes
Out[19]:
one object
two float64
three float64***
4 years ago
You could do something like this:
***df = df[['mean', '0', '1', '2', '3']]***
You can get the list of columns with:
***cols = list(df.columns.values)***
The output will produce:
***['0', '1', '2', '3', 'mean']***
...which is then easy to rearrange manually before dropping it into the first function
4 years ago
You can use **df.loc[i]**, where the row with index **i** will be what you specify it to be in the dataframe.
***
>>> import pandas as pd
>>> from numpy.random import randint
>>> df = pd.DataFrame(columns=['lib', 'qty1', 'qty2'])
>>> for i in range(5):
>>> df.loc[i] = ['name' + str(i)] + list(randint(10, size=2))
>>> df
lib qty1 qty2
0 name0 3 3
1 name1 2 4
2 name2 2 8
3 name3 2 1
4 name4 9 6
***
4 years ago
You can get the values as a list by doing:
***list(my_dataframe.columns.values)***
Also you can simply use:
***list(my_dataframe)***
4 years ago
Suppose **df** is your dataframe then:
***count_row = df.shape[0] # Gives number of rows
count_col = df.shape[1] # Gives number of columns***
Or, more succinctly,
***r, c = df.shape***
4 years ago
Use jQuery's is() function:
***if($("#isAgeSelected").is(':checked'))
$("#txtAge").show(); // checked
else
$("#txtAge").hide(); // unchecked
***
4 years ago
***/* do not group these rules */
*::-webkit-input-placeholder {
color: red;
}
*:-moz-placeholder {
/* FF 4-18 */
color: red;
opacity: 1;
}
*::-moz-placeholder {
/* FF 19+ */
color: red;
opacity: 1;
}
*:-ms-input-placeholder {
/* IE 10+ */
color: red;
}
*::-ms-input-placeholder {
/* Microsoft Edge */
color: red;
}
*::placeholder {
/* modern browser */
color: red;
}***
***

***

This will style all **input** and **textarea** placeholders.

**Important Note**: Do not group these rules. Instead, make a separate rule for every selector (one invalid selector in a group makes the whole group invalid).
4 years ago
For controlling "cellpadding" in CSS, you can simply use **padding** on table cells. E.g. for 10px of "cellpadding":
***td {
padding: 10px;
}***
For "cellspacing", you can apply the **border-spacing** CSS property to your table. E.g. for 10px of "cellspacing":

***table {
border-spacing: 10px;
border-collapse: separate;
}***
This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".
Issues in IE ? 7

This will work in almost all popular browsers except for Internet Explorer up through Internet Explorer 7, where you're almost out of luck. I say "almost" because these browsers still support the **border-collapse** property, which merges the borders of adjoining table cells. If you're trying to eliminate cellspacing (that is, **cellspacing="0"**) then **border-collapse:collapse** should have the same effect: no space between table cells. This support is buggy, though, as it does not override an existing **cellspacing** HTML attribute on the table element.

In short: for non-Internet Explorer 5-7 browsers, **border-spacing** handles you. For Internet Explorer, if your situation is just right (you want 0 cellspacing and your table doesn't have it defined already), you can use **border-collapse:collapse**.

***table {
border-spacing: 0;
border-collapse: collapse;
}***
Note: For a great overview of CSS properties that one can apply to tables and for which browsers, see this **fantastic Quirksmode page**.
4 years ago