Comments (8)
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.
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.
@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.
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.
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.
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.
@mifunetoshiro Dropplevel (0) removes the groubby name marked in following example:
Not the colum name themselves
from crypto-whale-watching-app.
ah okay, gotcha.
from crypto-whale-watching-app.
Related Issues (20)
- Adding OKEX info in separate version / integrated version HOT 1
- Is there a way to grab the results and store in Variable or print in console HOT 3
- Code on Plotly 3.0 stops working HOT 1
- Adding ETC HOT 2
- How to run HOT 1
- Help wanted with web hosting of app HOT 9
- Websocket empty? HOT 2
- Installation fails due to conflicting urllib3 version HOT 2
- app.py cannot work and got the error 'message': 'Failed to subscribe', 'reason': 'No channels provided' HOT 2
- error help HOT 1
- App doesn't work any more HOT 2
- Install erros - version conflicts HOT 3
- Crypto vs fiat HOT 1
- Does this still work?
- the code is nt update the data HOT 1
- Flask dependency error
- *-BTC pairs should be 5 decimals not 4 HOT 5
- noob issue, invalid syntax HOT 15
- Error: MacOS: Found existing installation six 1.4.1 HOT 2
- Time Stamping - Alt Coin Buzz HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crypto-whale-watching-app.