由于您正在阅读由带有多指数列的数据框架生产的CSV文件,因此在将其读回数据框架中时必须考虑到这一点。
尝试以下内容:
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()
tickers = "MYM=F M6A=F"
hist_data = pdr.get_data_yahoo(
tickers, period="1mo", interval="5m", prepost=True, group_by="ticker"
)
# Writing to csv-file
hist_data.to_csv("hist_data.csv")
# Reading back from csv-file
hist_data = pd.read_csv("hist_data.csv", index_col=0, header=[0, 1])
# Selecting the M6A=F/Volume-column:
volume = hist_data[[("M6A=F", "Volume")]]
print(volume)
第一个更改是使用index_col = 0
设置索引列(显然是第一个)。第二,header = [0,1]
是确保使用前2行用于构建多索引列。参见在这里
标题: int,int列表,none,默认'ceble'
...标题可以是指定列上多指数的行位置的整数列表...
结果:(
M6A=F
Volume
Datetime
2022-06-06 09:40:00-04:00 0.0
2022-06-06 09:45:00-04:00 67.0
2022-06-06 09:50:00-04:00 36.0
2022-06-06 09:55:00-04:00 18.0
2022-06-06 10:00:00-04:00 61.0
... ...
2022-07-06 09:20:00-04:00 47.0
2022-07-06 09:25:00-04:00 12.0
2022-07-06 09:30:00-04:00 7.0
2022-07-06 09:31:10-04:00 0.0
2022-07-06 09:31:20-04:00 NaN
[6034 rows x 1 columns]
我在此处使用了双括号hist_data [[[(“ m6a = f”,“ volume”)]
获取显示显示的数据框列标签。如果您不需要,请使用单个括号hist_data [(“ m6a = f”,“卷”)]
等)
get.context! 或 get.context作为buildContext
r“ ...”
是指 raw String
在Python中,这只是意味着将Backlash \
视为字面而不是逃生字符。
和(_ | - )[+]
是 正则表达式
匹配包含一个或多个的字符串 -
或_
字符。
如果您不能将re
库用于此解决方案:
def to_camel_case(text):
# Since delimiters can have 2 possible answers, let's simplify it to one.
# In this case, I replace all `_` characters with `-`, to make sure we have only one delimiter.
text = text.replace("_", "-") # the_big-red_apple => the-big-red-apple
# Next, we should split our text into words in order for us to iterate through and modify it later.
words = text.split("-") # the-big-red-apple => ["the", "big", "red", "apple"]
# Now, for each word (except the first word) we have to turn its first character to uppercase.
for i in range(1, len(words)):
# `i`start from 1, which means the first word IS NOT INCLUDED in this loop.
word = words[i]
# word[1:] means the rest of the characters except the first one
# (e.g. w = "apple" => w[1:] = "pple")
words[i] = word[0].upper() + word[1:].lower()
# you can also use Python built-in method for this:
# words[i] = word.capitalize()
# After this loop, ["the", "big", "red", "apple"] => ["the", "Big", "Red", "Apple"]
# Finally, we put the words back together and return it
# ["the", "Big", "Red", "Apple"] => theBigRedApple
return "".join(words)
print(to_camel_case("the_big-red_apple"))
这里的一行解决方案:
find *.txt | sed -E 'p;s/[, ]+/_/g' | tr '\n' '\0' | xargs -0 -n2 mv
这是一个非常有用的命令模板,用于重命名文件:
find ... | sed 'p;s/...' | tr '\n' '\0' | xargs -0 -n2 mv
手动链接已从React-Native 0.69中删除,有利于自动链接功能,因此现在您可以在本机模块中链接您的资产,否则您可以使用
react-nortiative-asset
剩下的步骤与板条箱中的crate相同
react-native.config.js
module.exports = {
project: {
ios: {},
android: {}
},
assets: ['./src/assets/'],
};
安装下面的React-Native-Asset运行下方
yarn react-native-asset or npx react-native-asset
问题是您在仍在循环的同时修改了while循环条件,并且在索引增加之前进行了变量分配。
description = logs[descriptionLine++];
这使得循环检查使用当前迭代的描述内容时,请检查上一行内容的状态。
让我们假设您的logs []
是由这3行制成的,我们以DescriptionLine = 0
开始:
line 0: blah blah at blah
line 1: blah blah at blah
line 2: something else
现在,
description = logs[0] // "line 0: blah blah at blah"
让我们查看while循环条件:
while (description.Contains("at") || description.Contains("---")) { ... }
条件得到满足,因为描述暂时包含“ at”一词,我们进入循环正文:
description = logs[descriptionLine++];
推迟++
您使用的增量操作员使Descript> DescriptionLine
变量>变量评估首先和然后增加。这意味着描述
变量的分配是 descript> descriptionline
值从0
到1 。
现在(这很重要),我们以 不变 描述
的方式离开了第一个循环。当我们启动第二个迭代时,description
的值仍然相同,因此我们进入了循环主体,但是DescriptionLine
值已从0 < /代码>
1
。推迟++
增量运算符再次使技巧重新解决:
description = logs[1] // "line 1: blah blah at blah"
但是当我们离开循环时,descriptionline
是2。最后,我们进入了第三和最后一个迭代
while (description.Contains("at") || description.Contains("---"))
Description
是“第1行:Blah blah in Blah”
,我们进入了身体,但我们处于第三次迭代,我们不应该进入!相反,这发生了:
description = logs[2] // "line 2: something else"
我们进行了另一个分配,因为现在Descriptline
已从1
2 增加。
我找到了解决方案。我验证了完整的实体,并查看了验证器中的对象,并找到了完整的实体。
当我考虑如何测试时,我进行了一些研究,并发现了其他相同的测试。我不知道这是否是最好的解决方案,但是我现在可以编写测试。
CondectValidatTestCase
<?php
namespace App\Tests\Validator\Constraint;
use App\Entity\Entity;
use App\Validator\MinimumAmount;
use App\Validator\MinimumAmountValidator;
use Symfony\Component\Validator\Context\ExecutionContext;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\ConstraintValidatorInterface;
class MinimumAmountValidatorTest extends ConstraintValidatorTestCase
{
/**
* @var ExecutionContextInterface
*/
protected $context;
/**
* @var ConstraintValidatorInterface
*/
protected $validator;
/**
* @var Constraint
*/
protected $constraint;
protected function setUp(): void
{
$this->constraint = new Entity();
$this->context = $this->createContext();
$this->validator = $this->createValidator();
$this->validator->initialize($this->context);
}
public function createValidator(): MinimumAmountValidator
{
return new MinimumAmountValidator();
}
public function createContext(): ExecutionContext
{
$myEntity = new Entity();
$myEntity->setCurrency('EUR');
$translator = $this->createMock(TranslatorInterface::class);
$translator->expects($this->any())->method('trans')->willReturnArgument(0);
$validator = $this->createMock(ValidatorInterface::class);
$executionContext = new ExecutionContext($validator, $myEntity, $translator);
$context->setNode('InvalidValue', null, null, 'property.path');
$context->setConstraint($this->constraint);
return $executionContext;
}
public function testValidation()
{
$this->validator->validate(40.00, new MinimumAmount());
$this->assertNoViolation();
}
}
约束
<?php
namespace App\Validator;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class MinimumAmount extends Constraint
{
/**
* @var string
*/
public $message = '';
/**
* @return string
*/
public function validatedBy(): string
{
return MinimumAmountValidator::class;
}
}
验证器
<?php
namespace App\Validator;
use App\Entity\Entity;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class MinimumAmountValidator extends ConstraintValidator
{
/**
* @param float $value
* @param Constraint $constraint
*
* @return void
*/
public function validate($value, Constraint $constraint)
{
/**
* @var Entity
*/
$contextRoot = $this->context->getRoot();
$currency = $contextRoot->getCurrency(); // EUR
$amount = $value; // 40.00
// Validation implementation
}
}
假设您有一个类classa
,其中包含方法methoda
定义为:
class ClassA:
def methodA(self, arg1, arg2):
... # do something
和objecta
是此类的实例。
现在,当调用objecta.methoda(arg1,arg2)
时,python内部将其转换为:
ClassA.methodA(objectA, arg1, arg2)
self
变量涉及对象本身。
这很简单,不用担心。您需要使用骗局(单个组件角模块)。下面为您提供的一个示例:
创建模块,仅导出一个组件! - 这是非常重要的
@NgModule({
declarations: [ModuleAComponent],
exports: [ModuleAComponent],
imports: [
ButtonModule // etc
],
})
export class ModuleA {}
模块中的进口模块 - 请参阅,这很简单
@NgModule({
declarations: [ModuleBComponent],
exports: [ModuleBComponent],
imports: [
ModuleB
],
})
export class ModuleB {}
我不确定您为什么要从堆栈继承而来,但是您对超级效力的问题非常简单。您应该使用 super.pop() [调用父级方法],而不是 this.pop() [调用此方法==递归调用]
@Override
public MyItem pop() {
if (this.isEmpty()) {
return null;
}
pops++;
return super.pop();
}
我目前有一个Raspberry Pi 4运行Ubuntu-22.04.2,我设法与MongoDB进行了适当的安装。
系统更新:
sudo apt-get update
sudo apt-get upgrade
需要安装libss1.1之前安装mongoDB:
sudo wget http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.18_arm64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.18_arm64.deb
sudo apt-get update
mongoDB:
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install mongodb-org=4.4.8 mongodb-org-server=4.4.8 mongodb-org-shell=4.4.8 mongodb-org-mongos=4.4.8 mongodb-org-tools=4.4.8
检查已安装版本:
mongod --version
启动Mongod:
sudo systemctl restart mongod
sudo systemctl status mongod
如果启动良好
sudo apt-mark hold mongodb-org*
安装
1)常规
2)输入绑定缓冲区
3)输出绑定缓冲区
如果不设置mysql_report_data_truncation(mysql_optionsv) , -Connector-C/Tree/3.3/Unitest/libmariaDB“ rel =“ nofollow noreferrer”> Mariadb连接器/C单元测试
1) General
2) input bind buffer
3) Output bind buffer
For some examples how to deal with prepared statements check the file ps.c of MariaDB Connector/C unit tests
可以通过MariaDB Connect/c准备的语句通过transmate字符串