import pandas_datareader
end = "2022-12-15"
start = "2022-12-15"
stock_list = ["TATAELXSI.NS"]
data = pandas_datareader.get_data_yahoo(symbols=stock_list, start=start, end=end)
print(data)
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,出现错误"TypeError: string indices must be integers"。
编辑:我已经更新了代码并将列表作为符号参数传递,但它仍然显示相同的错误
错误 :
Traceback (most recent call last):
File "C:\Users\Deepak Shetter\PycharmProjects\100DAYSOFPYTHON\mp3downloader.py", line 7, in <module>
data = pandas_datareader.get_data_yahoo(symbols=[TATAELXSI], start=start, end=end)
File "C:\Users\Deepak Shetter\PycharmProjects\100DAYSOFPYTHON\venv\lib\site-packages\pandas_datareader\data.py", line 80, in get_data_yahoo
return YahooDailyReader(*args, **kwargs).read()
File "C:\Users\Deepak Shetter\PycharmProjects\100DAYSOFPYTHON\venv\lib\site-packages\pandas_datareader\base.py", line 258, in read
df = self._dl_mult_symbols(self.symbols)
File "C:\Users\Deepak Shetter\PycharmProjects\100DAYSOFPYTHON\venv\lib\site-packages\pandas_datareader\base.py", line 268, in _dl_mult_symbols
stocks[sym] = self._read_one_data(self.url, self._get_params(sym))
File "C:\Users\Deepak Shetter\PycharmProjects\100DAYSOFPYTHON\venv\lib\site-packages\pandas_datareader\yahoo\daily.py", line …Run Code Online (Sandbox Code Playgroud) 我的时间戳Timestamp(seconds=1560523991, nanoseconds=286000000)在 Flutter Firestore 快照中返回。
我想将其打印为格式正确的日期和时间。
我DateTime.now()在创建新记录并使用 Firestore 快照检索它时使用将当前 DateTime 存储在 Firestore 中,但我无法转换为格式化的日期时间。我正在使用 libintl.dart进行格式化。
保存数据的代码
d={'amount':amount,
'desc':desc,
'user_id':user_id,
'flie_ref':url.toString(),
'date':'${user_id}${DateTime.now().day}-${DateTime.now().month}-${DateTime.now().year}',
'timestamp':DateTime.now()
return Firestore.instance.collection('/data').add(d).then((v){return true;
}).catchError((onError)=>print(onError));
});
Accessing with
FutureBuilder(
future: Firestore.instance
.collection('data')
.where('user_id', isEqualTo:_user_id)
.getDocuments(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return Container(
child: Center(child: CircularProgressIndicator()));
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
Text(DateFormat.yMMMd().add_jm().format(DateTime.parse(snapshot.data.documents[index].data['timestamp'].toString())]);
....
Run Code Online (Sandbox Code Playgroud)
抛出的错误是
日期格式无效。
我期待输出是: 'Jan 17, 2019, 2:19 PM'
在我导入 Xgboost 之前,一切在 Jupyter 笔记本中运行良好。一旦我导入它,我就会遇到下面的问题。我有 Python 3.8 并通过终端 pip3 方法安装了它,接下来我该怎么做?
---------------------------------------------------------------------------
XGBoostError Traceback (most recent call last)
<ipython-input-17-a81e4513ce38> in <module>
1 # Let's Learn about the stock market using XGBOOST
2
----> 3 import xgboost as xgb
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/__init__.py in <module>
9 import warnings
10
---> 11 from .core import DMatrix, DeviceQuantileDMatrix, Booster
12 from .training import train, cv
13 from . import rabit # noqa
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py in <module>
173
174 # load the XGBoost library globally
--> 175 _LIB = …Run Code Online (Sandbox Code Playgroud) 在我的项目中执行 NPM start 时遇到问题。我收到此错误消息:
./src/assets/base.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/react-scripts/node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/assets/base.scss)
Error: resolve-url-loader: CSS error
source-map information is not available at url() declaration (found orphan CR, try removeCR option)
Run Code Online (Sandbox Code Playgroud)
webpack sass-loader css-loader postcss-loader resolve-url-loader
由于下面的代码将显示一个没有 的情节plt.show(),有什么意义plt.show()?
请告诉我什么时候plt.show()需要,因为这会让我更好地理解 matplotlib 的复杂性。
注意:我在 Spyder (Anaconda) 中使用这个
import matplotlib.pyplot as plt
plt.subplot(211) # the first subplot in the first figure
plt.plot([1, 2, 3])
Run Code Online (Sandbox Code Playgroud) 我只是想运行第一个应用程序,这就是发生的事情:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> Several variant outputs are configured to use the same file name "resources-debug.ap_", filters : MAIN:MAIN
Run Code Online (Sandbox Code Playgroud) --lazy.module.ts 中的组件
const routes: Routes = [
{ path: 'memberdetails', component: MemberDetailsComponent },
{ path: 'leaves', component: LeavemanagementComponent },
{ path: 'attendance', component: AttendanceComponent }
];
Run Code Online (Sandbox Code Playgroud)
app-routing.module.ts
const routes: Routes = [
{ path: 'lazy', loadChildren: './lazy.module#LazyModule'},
];
Run Code Online (Sandbox Code Playgroud)
它在本地工作,但是当我单击上述任何链接时托管它后,我收到此错误...
vendor.05d559e….bundle.js:1 ERROR Error: Uncaught (in promise): Error:
Loading chunk 0 failed.
Error: Loading chunk 0 failed.
at HTMLScriptElement.r (inline.9786b27….bundle.js:1)
at HTMLScriptElement.L (polyfills.1a7da64….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at Object.onInvokeTask (vendor.05d559e….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at r.runTask (polyfills.1a7da64….bundle.js:1)
at t.invokeTask [as invoke] (polyfills.1a7da64….bundle.js:1) …Run Code Online (Sandbox Code Playgroud) 我有一个带有子组件的组件timeline。
<app-timeline [(editing)]="editingDate"></app-timeline>
Run Code Online (Sandbox Code Playgroud)
在时间轴组件中,我有这些属性:
@Input() editing: boolean; // <--- detect change on this
@Output() editingChange = new EventEmitter();
Run Code Online (Sandbox Code Playgroud)
如何检查editing时间线组件何时发生属性更改?每当编辑值发生变化时,我都需要发出编辑值。
我应该为编辑属性使用 setter 然后从那里发出吗?
private _editing
set editing() { ... // emit }
Run Code Online (Sandbox Code Playgroud)
或者还有其他方法吗?
我正在尝试用 networkx 和 Python 绘制简单的图形。
这是我的代码:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.complete_graph(5)
nx.draw(G, with_labels=True, font_weight='bold')
plt.show()
Run Code Online (Sandbox Code Playgroud)
但我收到错误
Message=random_state_index is incorrect
Source=***\PythonTest.py
StackTrace:
File "***\PythonTest.py", line 15, in <module>
nx.draw(G, with_labels=True)
Run Code Online (Sandbox Code Playgroud)
Python 3.7 64bit
OS Windows
networkx 2.2 ,2.3 或 2.5 也有同样的问题。
我正在将 Flask 与 HTML 和 CSS 结合使用。当这可能时:
<img src="{{ url_for('static', filename='images/planets.jpeg' ) }}">
Run Code Online (Sandbox Code Playgroud)
我必须在这里写什么来处理相同的图像?
.bgimg-1 {
background-image: url('https://i.ytimg.com/vi/J9QOB6hSI-c/maxresdefault.jpg');
min-height: 100%; }
Run Code Online (Sandbox Code Playgroud)
解决方案应与此类似:
.bgimg-1 {
background-image: url('{{ url_for('static', filename='images/planets.jpeg' ) }}');
min-height: 100%; }
Run Code Online (Sandbox Code Playgroud)
谢谢你。
python ×4
angular ×2
flutter ×2
android ×1
css ×1
css-loader ×1
dart ×1
flask ×1
html ×1
jinja2 ×1
jupyter ×1
lazy-loading ×1
matplotlib ×1
networkx ×1
sass-loader ×1
time ×1
webpack ×1
xgboost ×1