Home > database >  How to drop a column if the row value is less than 1000000
How to drop a column if the row value is less than 1000000

Time:11-09

I've been reading and trying for hours... I have a df like this:

                             BTC/USDT  ...                 MOVR/USDT
symbol                       BTC/USDT  ...                 MOVR/USDT
timestamp               1636391714488  ...             1636391711813
datetime     2021-11-08T17:15:14.488Z  ...  2021-11-08T17:15:11.813Z
close                65826.8800000000  ...            403.4000000000
percentage               6.0380000000  ...              4.4540000000
baseVolume           50096.1040200000  ...         111340.7360000000
quoteVolume     3255082473.3960447311  ...       46765144.8117000014

[7 rows x 349 columns]

I'm trying to drop columns where the 'quoteVolume is less than 1000000

I got this far...

        a = df.loc['quoteVolume'] > 10000000
        print(a)
       
BTC/USDT         True
ETH/USDT         True
BNB/USDT         True
BCC/USDT        False
NEO/USDT         True
                ...  
AUCTION/USDT    False
DAR/USDT         True
BNX/USDT        False
RGT/USDT        False
MOVR/USDT        True
Name: quoteVolume, Length: 349, dtype: bool

CodePudding user response:

A bool mask does the trick:

df.loc[:,df.loc[('quoteVolume',:]>1000000)] 

CodePudding user response:

Finally after 9hrs of trying.

 a = df.loc[:,df.loc['quoteVolume'] > 1000000]
 print(a)
  • Related