如果我要統計台灣的股票台積電近一個月的成交金額,可以給我python程式碼嗎
Private research annotation
Sign in to add a private research label or note.
Jump to turn (27)
- 1如果我要統計台灣的股票台積電近一個月的成交金額,可以給我python程式碼嗎
- 2如果我要列出台灣的股票殖利率高於5%,可以給我python程式碼嗎
- 3/usr/local/lib/python3.9/dist-packages/pandas/core/internals/construction.py in
- 4可以給我修正過的程式碼嗎
- 5請給我修正過的程式碼,我要列出台灣的股票殖利率高於5%
- 6這個程式會出現AttributeError: module 'pandas.compat' has no attribute 'StringIO'
- 7但是又出現ParserError: Error tokenizing data. C error: Expected 1 fields in line 3, s
- 8colab說這行程式有誤df = pd.read\csv(io.StringIO("\n".join(data[1:])), header=None)
- 9還是會出現ParserError: Error tokenizing data. C error: Expected 1 fields in line 3, s
- 10程式依然無法執行
- 11請給我可以在COLAB執行的python程式碼,我要列出台灣的股票殖利率高於5%
- 12df = dfdf["殖利率"] > 5] 出現底下錯誤 TypeError: '>' not supported between instances of '
- 13The error\bad\lines argument has been deprecated and will be removed in a future
- 14只出現底下答案 Empty DataFrame Columns: [股票代號, 殖利率, 股票名稱] Index: []
- 15改了還是出現一樣的答案
- 16會不會的給的連結資料有誤
- 17請給我可以解決問題的程式碼
- 18import requests from io import StringIO import pandas as pd 下載股票資料 url = "https:
- 19這樣沒有任何資料
- 20https://www.twse.com.tw/exchangeReport/BWIBBU\d?response=csv&date={}&selectType=
- 21我要整年的
- 22那給我2023年2月份的殖利率大於5%
- 232021年2月的呢
- 24我不是要一天的,而是要整個月份的
- 25請給我計算台積電買點的python程式
- 26請給我計算台積電買點的python程式碼
- 27股票賣點的程式碼呢
- User
如果我要統計台灣的股票台積電近一個月的成交金額,可以給我python程式碼嗎
- Assistant
當然,你可以使用以下的Python程式碼來統計台灣股市上台積電(Taiwan Semiconductor Manufacturing Company Limited)在近一個月內的成交金額。
pythonimport requests import pandas as pd url = 'https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220301&stockNo=2330' res = requests.get(url) data = res.json()['data'] df = pd.DataFrame(data, columns=['date', 'shares', 'amount', 'open', 'high', 'low', 'close', 'change', 'transaction']) df['amount'] = pd.to_numeric(df['amount'].str.replace(',', '')) total_amount = df['amount'].sum() print(f'Total amount of TSMC traded in the past month is {total_amount:,} NTD.')