I want to filter column on specific names in column, and delete these - pandas

I have values in my dataframe column that are bad for my data and I need to remove them, I only know how to do this with one row:
df=df[df.name!='susan']
but I want to delete 4 other names within my column

Related

How to remove rows in a dataframe whose column values are not in a list

I have a dataframe with several different possible values for a particular column. I also have a set that has the column values of rows that I actually care about. I want to update the dataframe such that it removes all rows whose column values are not found in the list I made . How would I do this?
If I get your question then, for a given column col you could do something like this:
df = df.loc[df[col].isin(your_list)]

Adding column values to one row

I am creating a attendance sheet and i want to know how to combine all values of a column from a sql table to a single row and display it in the datagridview like this for example:

How to reorganise a table basis a criteria

I have a table where columns exist at different rows as shown in Problem figure.
I am able to identify the rows of column headers (Numbered 1 in column A) and there values(Numbered 2,3 onwards in Column A).
I want collate it in a neat table as shown in Solution table; where all Column headers are in one row and subsequently we have their values.
Problem and expected results are as shown in picture

Clear a particular column of data table in vb

I have a data table which has 3 columns . I am populating the values of each column separately in a loop which causes the table structure to be in the format as shown in the image. How to clear every column at the beginning of the loop so that all data comes in a proper tabular format. In short I want to have a data table with variable number of rows possible for each column.
To clear every column at beginning of the loop you have two options:
loop all rows
remove column, add column
Depending on the plenty of rows the two options have different performances.
For large amount of rows i prefer the second option.

How would you total the values in one column and keep a distinct value in another?

I have a database table that has multiple codes in one column that correspond to certain values in another column. For example, a particular code in column A corresponds to a value in column B. There are thousands of duplicate entries in column A that correspond to different values in column B. I want to add up all of the values in column B that have the particular code in column A, while only keeping one copy of the code from column A. You may think of the columns as key-value pairs, where column A contains the key and column B contains the value.
Basically, I want to add all the values in column B where column A is a specific value, and I want to do for this all of the unique "keys" in column A. I'm sure that this is a simple task; however, I am pretty new to SQL. Any help would be greatly appreciated.
Here is the result I'm looking for.
This should work:
SELECT
A,
SUM(B) AS sum_b
FROM [yourTable]
GROUP BY A
SELECT COLUMNA, SUM(ISNULL(COLUMNB,0)) AS TOTAL
FROM
dbo.TableName
GROUP BY COLUMNA