Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

drop list of columns pandas

df.drop([item for item in total_cols if item not in columns_in_use], axis=)
Comment

python - dataframe columns is a list - drop

# Df with a coulmn (dims) that contain list
key1 = 'site channel fiscal_week'.split()
key2 = 'site dude fiscal_week'.split()
key3 = 'site eng fiscal_week'.split()

keys = pd.DataFrame({'key': [1,2,3],
                     'dims': [key1,key2,key3]})

# Output
                         dims  key
[site, channel, fiscal_week]    1
[site, dude, fiscal_week]       2
[site, eng, fiscal_week]        3


# Solution
keys['reduced_dims'] = keys['dims'].apply(
    lambda row: [val for val in row if val != 'fiscal_week']
)
Comment

PREVIOUS NEXT
Code Example
Python :: print fps in while loop python 
Python :: The module in NAME could not be imported: django.contrhtmlib.auth.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALIDATORS setting. 
Python :: docstrinfs pyt 
Python :: tuple parameter function python is None 
Python :: topaz barziv 
Python :: run a python script with python and catch command line output 
Python :: django clodinarystorage 
Python :: discord py aliases 
Python :: python how to count ever yfile in fodler 
Python :: file.write must be string python 
Python :: python3 array 
Python :: Return an RDD of grouped items. 
Python :: what is mi casa in spanish 
Python :: python how to move multiple values from one list to another at once 
Python :: dict from group pandas 
Python :: tensorflow loop csdn 
Python :: come traferire file python 
Python :: r value on poly fit python 
Python :: how to find all the installed packages in python 
Python :: python create a lsit 
Python :: python writelignes 
Python :: pandas use map lambda to fillna python 
Python :: r stagazer html knit 
Python :: exercism Phone Number python 
Python :: python get all items from generator 
Python :: python read text file to list 
Python :: cptac dataset 
Python :: how to find pandoc template folder 
Python :: python opening file modalities 
Python :: stdfilt python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =