If I have given names to different DataTable columns and
those column names are stored in a variable, then passing
that variable to the datatable how can i Enter different
values in those columns listed in that variable?? Please
explain me with an example.I am not getting it.
Answer / Anupriya Ekka
You can use the `Add()` method to add rows to a DataTable using a variable containing column names. Here's an example:
C#:
```csharp
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name"), new DataColumn("Age") });
string[] columnNames = { "Name", "Age" };
for (int i = 0; i < 5; i++)
{
dt.Rows.Add(columnNames, "Person_" + i, i * 10);
}
```
Python:
```python
import pandas as pd
df = pd.DataFrame(columns=["Name", "Age"])
columns = ["Name", "Age"]
for i in range(5):
df = df.append({col: f"Person_{i}" for col in columns}, ignore_index=True)
```
In both examples, a DataTable (DataFrame in Python) is created with two columns named 'Name' and 'Age'. Then, a variable `columnNames` contains the column names. Using a loop, rows are added to the DataTable/DataFrame where each row's values are stored in variables prefixed with "Person_". The variables for each column's value are created using the same pattern as the column name.
| Is This Answer Correct ? | 0 Yes | 0 No |
What could go wrong with test automation?
how is mind q venkat training in testing for weekend or general batches.and any other good institutes in ameerpet
How does load testing work for websites?
what is are the difference between qtp and selenium ?
What tools are available for support of testing during software development life cycle?
What is hybrid automation?
How do you identify the test cases which are suitable for automation?
List some advantages and disadvantages of automation testing.
How software testing is handled?
hi friends.....please help me...i have very ambiguity which one be selected between selenium or ETL-TESTING..
Is automation testing a black box testing or white-box testing?
is there any Rational Functional Tester certification questions available?