我在使用if语句评估字典中的值时遇到了麻烦.
给出以下字典,我从数据框导入(如果它很重要):
>>> pnl[company]
29: Active Credit Date Debit Strike Type
0 1 0 2013-01-08 2.3265 21.15 Put
1 0 0 2012-11-26 40 80 Put
2 0 0 2012-11-26 400 80 Put
Run Code Online (Sandbox Code Playgroud)
我尝试评估以下语句以确定最后一个值的值Active:
if pnl[company].tail(1)['Active']==1:
print 'yay'
Run Code Online (Sandbox Code Playgroud)
但是,我遇到以下错误消息:
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
if pnl[company].tail(1)['Active']==1:
File "/usr/lib/python2.7/dist-packages/pandas/core/generic.py", line 676, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Run Code Online (Sandbox Code Playgroud)
这让我感到惊讶,因为我可以在没有if语句的情况下使用上面的命令显示我想要的值:
>>> pnl[company].tail(1)['Active']
30: …Run Code Online (Sandbox Code Playgroud) 我想强制使用yarn install而不是npm install.我想提出错误npm install.我该怎么办package.json?
我一直在使用Webpack,Vue.js和Rails开发一个应用程序.两个月没有问题,但是当我尝试启动rails console时无处不在rails c,yarn抱怨包已过时:
error An unexpected error occurred: "Unknown language key integrityNodeDoesntMatch".
info If you think this is a bug, please open a bug report with the information provided in "/Users/maksimfedotov/vras/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.
========================================
Your Yarn packages are out of date!
Please run `yarn install` to update.
========================================
Run Code Online (Sandbox Code Playgroud)
然而,当我跑yarn install:
yarn install v1.3.2
[1/4] Resolving packages...
success Already up-to-date.
? Done in 0.71s.
Run Code Online (Sandbox Code Playgroud)
我一直在查看yarn和webpacker文档,尝试了各种yarn清理命令,但没有运气.
有趣的是,我仍然可以运行服务器,它唯一抱怨的控制台.
我知道之前有人问过它,但是depcheck似乎根本不适合我。除了必须为“仅配置”库(如 babel、eslint 等)配置它之外,它还给了我大量的错误警报。
如果你接到这样的任务,你的方法是什么?你有什么最佳实践可以推荐给我吗?
谢谢!
运行后yarn config set registry https://registry.yarnpkg.com/,Yarn 不断使用错误的注册表——在这种情况下,是https://registry.npmjs.org/。
这是来自的输出yarn config list:
yarn config v1.13.0
info yarn config
{ 'version-tag-prefix': 'v',
'version-git-tag': true,
'version-commit-hooks': true,
'version-git-sign': false,
'version-git-message': 'v%s',
'init-version': '1.0.0',
'init-license': 'MIT',
'save-prefix': '^',
'bin-links': true,
'ignore-scripts': false,
'ignore-optional': false,
registry: 'https://registry.yarnpkg.com/',
'strict-ssl': true,
'user-agent': 'yarn/1.13.0 npm/? node/v8.11.4 linux x64',
lastUpdateCheck: 1552699471443 }
info npm config
{ 'strict-ssl': false,
ca: '',
registry: 'https://registry.yarnpkg.com/' }
Run Code Online (Sandbox Code Playgroud)
正如你从输出中看到的,我也跑来npm config set registry ttps://registry.yarnpkg.com/避免混淆。我还检查了 .npmrc 和 .yarnrc 文件中是否有对 npmjs …
在一个更大的打字稿项目上工作,我们决定将代码移动到带有纱线工作空间的monorepo .
我们使用webpack来构建和捆绑,一切运行良好(特别是本地模块/包之间的链接).
由于纱线工作区将大多数node_modules存储在mono repo的根文件夹中,因此IDE(IntelliJ以及VSCode)在"内部"项目(所谓的"monorepo"的"包")内编码时解决了对任何node_modules的导入问题. ).
奇怪的是,导入是未知的,但另一方面,如果您手动将其导入,则大多数情况下您可以在IDE中导航到相同导入的IDE中的正确源/定义.
我们试图告诉IntelliJ查看node_modules的另一个文件夹,但仍然不满意.
请分享您对纱线工作空间/ monorepo(例如lerna)的体验以及您如何开发生活在这些单体中的代码.
你使用哪个IDE?
您是否在IDE和/或package.json,tsconfig.json中添加了任何特殊配置?
我在我的web项目中使用Angular 5.2.0和Bootstrap 4.我安装了bootstrap 4 npm i bootstrap --save,它告诉我有关未满足的对等依赖项:
npm WARN bootstrap@4.0.0 requires a peer of jquery@>=3.0.0 but none was installed.
npm WARN bootstrap@4.0.0 requires a peer of popper.js@^1.11.0 but none was installed.
Run Code Online (Sandbox Code Playgroud)
当然,Bootstrap的JS依赖于这些对等依赖.到目前为止,这么平常.
问题是:我不使用任何Bootstraps JS.我正在使用ng-bootstrap,这是为Angular重写的Bootstrap组件.
这个警告让我感到很恼火,因为它真的不是一件事,当我还没有使用它时(这个项目中没有其他人应该 - 在尝试使用Bootstrap的组件本身时会出错).清洁代码和依赖项不应输出任何警告.
为了摆脱这个警告,我尝试了不同的方法:
bootstrap包.package.json未使用的依赖关系- 并且在清洁代码环境中也应避免(imho).那么:有没有办法以干净的方式处理这些对等依赖警告?
我正在做的就是运行create-react-app和cd'ing到应用程序,然后尝试运行npm/yarn start.我得到以下错误/输出/日志.我已经完成了所有建议的步骤.唯一有效的是我的.env中的SKIP_PREFLIGHT_CHECK = true作为Yarn和npm的最后手段.我最近更新到Mojave,如果人们有类似的经历,我不得不重新安装我的Xcode.
如果图像不够,我粘贴下面的输出.
非常感谢你提前帮助...杰森
控制台截图 
Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start
> react-express-graphql-app@0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "23.6.0"
Don't try to install it manually: your package …Run Code Online (Sandbox Code Playgroud) 是什么yarn build命令呢?是yarn build和npm build一样吗?如果没有,有什么区别?
我在我的存储库中使用 Yarn Workspaces 并使用 AWS CodeBuild 来构建我的包。构建开始时,CodeBuild 需要 60 秒来安装所有包,我想避免这次缓存node_modules文件夹。
当我添加:
cache:
paths:
- 'node_modules/**/*'
Run Code Online (Sandbox Code Playgroud)
到我的buildspec文件并启用LOCAL_CUSTOM_CACHE,我收到此错误:
错误发生意外错误:“EEXIST:文件已存在,mkdir '/codebuild/output/src637134264/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/MY_REPOSITORY/node_modules/@packages/configs '”。
有没有办法消除配置 AWS CodeBuild 或 Yarn 的错误?
我的构建规范文件:
version: 0.2
phases:
install:
commands:
- npm install -g yarn
- git config --global credential.helper '!aws codecommit credential-helper $@'
- git config --global credential.UseHttpPath true
- yarn
pre_build:
commands:
- git rev-parse HEAD
- git pull origin master
build:
commands:
- yarn run build
- yarn run deploy …Run Code Online (Sandbox Code Playgroud) yarnpkg ×9
npm ×6
node.js ×2
reactjs ×2
angular ×1
bootstrap-4 ×1
ide ×1
if-statement ×1
javascript ×1
macos ×1
monorepo ×1
package.json ×1
pandas ×1
python ×1
series ×1
webpack ×1