Questions tagged [drop]

468 questions
-1
votes
1 answer

How to drop certain rows from dataframe if they partially meet certain condition

I'm trying to drop rows from dataframe if they 'partially' meet certain condition. By 'partially' I mean some (not all) values in the cell meet the condition. Lets' say that I have this dataframe. >>> df Title …
MongMong
  • 31
  • 6
-1
votes
1 answer

Removing a constraint in T-SQL by alter table command - problem

I have got the following code in t-SQL: alter table Persons drop primary key; And the message: Msg 156, Level 15, State 1, Line 10 Incorrect syntax near the keyword 'primary'. I have checked different combinations of syntax and none have…
-1
votes
1 answer

While loop does not go to the beginning

I have written python while loop that intercats with user input . There is a table with dates columns. The idea is that the user being asked if it wantes to remove cols from the table. if yes, then it needs to specified the column from a given list.…
Reut
  • 1,555
  • 4
  • 23
  • 55
-1
votes
1 answer

how can I return column that i already deleted in dataframe pandas

Using df.drop() I removed the "ID" column from the df, and now I want to return that column. df.drop('ID', axis=1, inplace=True) df # shows me df without ID column What method should I use?
-1
votes
1 answer

Unable to drop foreign key in SQL server

I am trying this query to drop a foreign key ALTER TABLE dbo.[User] DROP FOREIGN KEY FK_User_UserTypeID. But I am getting this Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'FOREIGN'.
Moeez
  • 494
  • 9
  • 55
  • 147
-1
votes
1 answer

How to drop rows in a df based on NaN values in specific columns not using column names but integer position for the subset?

I have a dataframe with 9 columns (long cryptic column names) and ~1000 rows. I want to drop/delete merely the rows where the values in column 2 and 3 are NaN. I know there is DataFrame.dropna(subset=[]) but I don't want to select the columns by…
vossa
  • 15
  • 6
-1
votes
2 answers

Drop column that contain certain values in a number of rows in Pyspark

So I have a pyspark dataframe, it contains 12 rows and 50 columns. I want to drop the columns that contains 0 more than 4 rows. However the answers in the above question are only for pandas. Is there a solution for pyspark dataframe?
mojek
  • 195
  • 1
  • 9
-1
votes
1 answer

How can I ensure a foreign key constraint doesn't exist, if I don't know whether the table exists?

If I know that the table exists but I don't know whether the foreign key constraint exists, then I can do this: ALTER TABLE table_name DROP CONSTRAINT IF EXISTS constraint_name What if I don't know whether the table itself exists? I want a single…
Hammerite
  • 21,755
  • 6
  • 70
  • 91
-1
votes
2 answers

Drop rows of NaN with a slice of columns in Pandas

I have hundreds of columns in a DataFrame and would like to drop rows where multiple columns are NaN. Meaning entire row is NaN for those columns. I have tried to slice columns but the code is taking forever to run. df =…
M A
  • 73
  • 1
  • 2
  • 10
-2
votes
1 answer

Drop a row if the only label in the numeric rows is one class

I have a df where i hot encoded 28 clases with text, for a multi label process. My question is how I can drop a row if any value in the row equals zero, except for one column, that i want to chose. I'm using jupyter with python 3, and i cant get it.
-2
votes
1 answer

drop_na in RStudio

I am unable to run the following on RStudio penguins %>% group_by(island) %>% drop_na(.) %>% summarise(mean_bill_length_mm = mean(bill_length_mm)) The error coming up is Error in drop_na(.) : could not find function "drop_na" What do I have to do to…
Palak Parekh
  • 3
  • 1
  • 2
-2
votes
1 answer

How to merge two data to one in a given column in python

How're you today? I am having difficulty in treating the gender column, considering it has a data entry error "Fe male". Can it be dropped? If yes, how can I go about it? Can it be merged? If yes, how can I treat this? Thank you.
Zeezou
  • 1
  • 1
-2
votes
1 answer

Delete rows in a dataframe by a range of dates

I have a dataframe with a column 'date' (YYYY-MM-DD HH:MM:SS) and datetime64 type. I want to drop/eliminate rows by selecting ranges of dates. How can I do this on python/pandas? Thank you so much in advance
-2
votes
1 answer

How to recreate table in MYSQL?

I am sorry for my bad English. Okay? my problem is i need to recreate temporary table many times (more then 5). I need totally change structure of table. I try do it like this but i have errors CREATE TABLE #DeletedData (RoleName varchar(max), …
-3
votes
1 answer

Type Error : NoneType is not subscriptable

for i in Leads.columns: if (Leads[i].isnull().sum()/Leads.shape[0]) > 0.40: Leads = Leads.drop(i,axis=1,inplace = True) --------------------------------------------------------------------------- TypeError …
1 2 3
31
32