Giter VIP home page Giter VIP logo

Comments (8)

mifunetoshiro avatar mifunetoshiro commented on July 24, 2024 1

Yes, but in the way that I did it:

    vol_grp_bid = bid_tbl.groupby([TBL_VOLUME]).agg({TBL_PRICE: [np.min, np.max, 'count'], TBL_VOLUME: np.sum, 'total_price': np.sum})
    vol_grp_bid.columns = ['min_Price', 'max_Price', 'count', 'volume', 'total_price']
    vol_grp_ask = ask_tbl.groupby([TBL_VOLUME]).agg({TBL_PRICE: [np.min, np.max, 'count'], TBL_VOLUME: np.sum, 'total_price': np.sum})
    vol_grp_ask.columns = ['min_Price', 'max_Price', 'count', 'volume', 'total_price']

It's not needed, because there aren't 2 levels, and you get an error:

AttributeError: 'Index' object has no attribute 'droplevel'

from crypto-whale-watching-app.

theimo1221 avatar theimo1221 commented on July 24, 2024

Wich Error and are you sure it´s on that line and not cause error in line before?
@mifunetoshiro I made a pull request into your patch repo, try it in there my changes will do many things in other ways

from crypto-whale-watching-app.

mifunetoshiro avatar mifunetoshiro commented on July 24, 2024

@theimo1221 This error, see the code I tried: mifunetoshiro@7647a92

Exception in thread Thread-57:
Traceback (most recent call last):
File "C:\Python\lib\site-packages\pandas\core\indexes\base.py", line 2525, in get_loc
return self._engine.get_loc(key)
File "pandas_libs\index.pyx", line 117, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 139, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1265, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1273, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'volume'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Python\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\mifune\Desktop\app.py", line 596, in recalcThread
count = count+1 if (not calc_data(pair)) else 0
File "C:\Users\mifune\Desktop\app.py", line 223, in calc_data
((vol_grp_bid[TBL_VOLUME] >= minVolume) & (vol_grp_bid['count'] >= 2.0) & (vol_grp_bid['count'] < 70.0))]
File "C:\Python\lib\site-packages\pandas\core\frame.py", line 2139, in getitem
return self._getitem_column(key)
File "C:\Python\lib\site-packages\pandas\core\frame.py", line 2151, in _getitem_column
result = result[key]
File "C:\Python\lib\site-packages\pandas\core\frame.py", line 2139, in getitem
return self._getitem_column(key)
File "C:\Python\lib\site-packages\pandas\core\frame.py", line 2146, in _getitem_column
return self._get_item_cache(key)
File "C:\Python\lib\site-packages\pandas\core\generic.py", line 1842, in _get_item_cache
values = self._data.get(item)
File "C:\Python\lib\site-packages\pandas\core\internals.py", line 3843, in get
loc = self.items.get_loc(item)
File "C:\Python\lib\site-packages\pandas\core\indexes\base.py", line 2527, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas_libs\index.pyx", line 117, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 139, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1265, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1273, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'volume'

from crypto-whale-watching-app.

mifunetoshiro avatar mifunetoshiro commented on July 24, 2024

Ah, I see: rename(columns={'amin': 'min_Price', 'amax': 'max_Price', 'sum': 'volume', 'sum': 'total_price'})

This renames both sum columns to 'total_price' instead of 'volume' and 'total_price'. So how do you rename two sums to two different names?

from crypto-whale-watching-app.

theimo1221 avatar theimo1221 commented on July 24, 2024

vol_grp_ask = ask_tbl.groupby([TBL_VOLUME]).agg({TBL_PRICE: [np.min, np.max, 'count'], TBL_VOLUME:{TBL_VOLUME:np.sum}, 'total_price': {'total_price':np.sum}).rename(columns={'amin': 'min_Price', 'amax': 'max_Price'})

Is what you need I guess

from crypto-whale-watching-app.

mifunetoshiro avatar mifunetoshiro commented on July 24, 2024

Ok, I figured it out. Instead of using the rename function, I manually renamed the columns with vol_grp_bid.columns. This is also unneeded after: vol_grp_bid.columns.droplevel(0)

Will add pull request soon.

Edit: your way produces this warning:

FutureWarning: using a dict with renaming is deprecated and will be removed in a future version

from crypto-whale-watching-app.

theimo1221 avatar theimo1221 commented on July 24, 2024

@mifunetoshiro Dropplevel (0) removes the groubby name marked in following example:
image

Not the colum name themselves

from crypto-whale-watching-app.

theimo1221 avatar theimo1221 commented on July 24, 2024

ah okay, gotcha.

from crypto-whale-watching-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.