0

So i have this dataframe:

dfprices = pd.DataFrame(prices)

dfprices

 pd.Dataframe = (             
         price         symbol
0        0.10566500    ETHBTC
1        0.01643000    LTCBTC
2        0.00112080    BNBBTC
3        0.01423200    NEOBTC
4        0.00030000    123456
5        0.03393500   QTUMETH
6        0.01077400    EOSETH
7        0.00022600    SNTETH
8        0.00630600    BNTETH
9        0.14548000    BCCBTC
10       0.00599900    GASBTC
11       0.01059800    BNBETH
12   10294.77000000   BTCUSDT
13    1089.99000000   ETHUSDT
14       0.00142500    HSRBTC )

From this i want to

  1. select only the rows where the text in comlumn 'symbol' ends with 'BTC'.
  2. Next i want to remove 'BTC' from the strings in column 'symbol'

For this i used following code:

dfcleanprices = dfprices[dfprices['symbol'].str[-3:]=="BTC"]
dfcleanprices['symbol'] = dfcleanprices['symbol'].str[:-3]

I ge the result that i want:

dfcleanprices

  pd.Dataframe = (          
         price         symbol
    0    0.10566500    ETH
    1    0.01643000    LTC
    2    0.00112080    BNB
    3    0.01423200    NEO
    9    0.14548000    BCC
    10   0.00599900    GAS
    14   0.00142500    HSR
    19   0.00105000    MCO
    20   0.00324080    WTC
    22   0.00009404    LRC
    24   0.00358700   QTUM)

But by executing the second statement a warning is shown:

SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  from binance.client import Client

I tried a lot but i really need help :)

wouter
  • 1
  • 2
  • 1
    Possible duplicate of [How to deal with SettingWithCopyWarning in Pandas?](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – Nathan Clement Jan 30 '18 at 22:32
  • You'll get an answer faster if you build a snippet of your dataframe in here vs. just posting an image. Build with e.g. pd.DataFrame=(...). Hard to fix w/o. – EHB Jan 30 '18 at 22:33
  • Put in the pd.DataFrame snippits. thnx – wouter Jan 30 '18 at 22:58

0 Answers0