Comments (3)
Traceback (most recent call last):
File "a.py", line 12, in
print(krx.get_shorting_status_by_date("20181210", "20181212", "005930"))File "D:\0.prj_python\pykrx-master\pykrx\krx.py", line 53, in get_shorting_status_by_date
return SRT02010100.scraping(isin, fromdate, todate)File "D:\0.prj_python\pykrx-master\pykrx\shorting.py", line 48, in scraping
df = df.replace({',': ''}, regex=True).astype(np.int64)File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\generic.py", line 5681, in astype
**kwargs)
File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\internals\managers.py", line 531, in astype
return self.apply('astype', dtype=dtype, **kwargs)
File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\internals\managers.py", line 395, in apply
applied = getattr(b, f)(**kwargs)
File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\internals\blocks.py", line 534, in astype
**kwargs)
File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\internals\blocks.py", line 633, in _astype
values = astype_nansafe(values.ravel(), dtype, copy=True)
File "D:\python372\lib\site-packages\pandas-0.24.0rc1-py3.7-win32.egg\pandas\core\dtypes\cast.py", line 685, in astype_nansafe
return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)
File "pandas_libs\lib.pyx", line 530, in pandas._libs.lib.astype_intsafeValueError: invalid literal for int() with base 10: '40,002'
Modify shorting.py with below code
df = df.replace(',','', regex=True).astype(np.int64)
# df = df.replace({',': ''}, regex=True).astype(np.int64)
from pykrx.
@sketchout Sorry for the slow reply. Could you find out which version of Pandas you're using?
import pandas
print(pandas.__version__)
astype(np.int64)
is required for arithmetic operations of API results.
>> df = krx.get_shorting_status_by_date("20181210", "20181212", "005930")
>> sum(df['공매도'])
2922537
from pykrx.
The latest version (0.24.1) does not replace comma separator, but 0.23.4 does.
df = pd.DataFrame({'one': ["1,000", "2,000"], 'two': ["3,000", "4,000"]})
df = df.replace({',': ''}, regex=True)
print(df)
In 0.23.4, it works!
one two
0 1000 3000
1 2000 4000
In 0.24.1, it does NOT work!
one two
0 1,000 3,000
1 2,000 4,000
To avoid version problems, I used "value" parameter instead of "to_relace" parameter with dictionary.
df = df.replace(',', '', regex=True)
from pykrx.
Related Issues (20)
- get_market_trading_value_by_date 함수를 실행하면 빈 dataFrame을 가져옵니다. HOT 3
- 특정 ip에서 pystock.get_market_ticker_list(market='KOSPI')를 하면 에러가 뜹니다. HOT 2
- 어제까지 작동하던 함수가 빈값으로 조회됩니다 HOT 3
- get_market_cap_by_date 문제 HOT 2
- Can't get market fundamental and other info. since 18:13, July 5 2024 HOT 4
- get_market_ticker_list HOT 2
- stock.get_market_ticker_list() 오류 HOT 2
- stock.get_market_trading_volume_by_date 에러 HOT 2
- get_market_ticker_list(), get_market_ticker_name() 등 오류가 나옵니다. HOT 3
- get_market_fundamental_by_date() 오류 건 HOT 2
- get_market_ticker_list()오류 HOT 1
- df = stock.get_market_trading_value_by_date("20210115", "20210122", "005930") print(df.head()) HOT 2
- pykrx 오류 관련. HOT 1
- KRX 사이트 내부 데이터 변경으로 KRX 관련 pykrx 오류 문제 (fdr 에서도 동일 이슈) HOT 1
- 최근 오류 HOT 4
- 분별 OHLCV 조회는 없나요? HOT 2
- stock.get_market_ohlcv() 거래대금 누락 HOT 2
- krx쪽 아예 전부 조회가 안되는 것 같습니다. referer인가 추가해봐도 안되는데 다른 분들은 어떻게 해결하셨는지 모르겠네요. HOT 3
- get_otc_treasury_yields 값 공란으로 출력되는 오류 HOT 1
- 오늘부터 갑자기 티커 리스트 조회가 안되네요
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 pykrx.