功夫熊猫中英文字幕版好句子

SettingWithCopyWarning is one of the most common hurdles people run into when learning pandas. A quick web search will reveal scores of Stack Overflow questions, GitHub issues and forum posts from programmers trying to wrap their heads around what this warning means in their particular situation. It’s no surprise that many struggle with this; there are so many ways to index pandas data structures, each with its own particular nuance, and even pandas itself does not guarantee one single outcome for two lines of code that may look identical.

SettingWithCopyWarning是学习熊猫时人们遇到的最常见的障碍之一。 快速的网络搜索将揭示数十个Stack Overflow问题,GitHub问题以及程序员的数十个帖子,这些帖子试图使头脑风暴,以了解在特定情况下此警告的含义。 毫不奇怪,许多人为此感到挣扎。 索引熊猫数据结构的方法有很多,每种方法都有其特定的细微差别,甚至熊猫本身也不能保证看起来相同的两行代码的单一结果。

This guide explains why the warning is generated and shows you how to solve it. It also includes under-the-hood details to give you a better understanding of what’s happening and provides some history on the topic, giving you perspective on why it all works this way.

本指南说明了生成警告的原因,并向您展示了如何解决它。 它还包括引擎盖下的详细信息,以使您对正在发生的事情有更好的了解,并提供有关该主题的一些历史记录,从而使您可以了解为何一切都以这种方式起作用。

In order to explore SettingWithCopyWarning, we’re going to use a data set of the prices of Xboxes sold in 3-day auctions on eBay from the book Modelling Online Auctions. Let’s take a look:

为了探索SettingWithCopyWarning ,我们将使用Modeling Online Auctions一书中在eBay上为期3天的拍卖中出售的Xbox的价格数据集。 让我们来看看:

import import pandas pandas as as pdpddata data = = pdpd .. read_csvread_csv (( 'xbox-3-day-auctions.csv''xbox-3-day-auctions.csv' )
)
datadata .. headhead ()
()

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱
0 0 8213034705 8213034705 95.0 95.0 2.927373 2.927373 jake7870 jake7870 0 0 95.0 95.0 117.5 117.5
1 1个 8213034705 8213034705 115.0 115.0 2.943484 2.943484 davidbresler2 davidbresler2 1 1个 95.0 95.0 117.5 117.5
2 2 8213034705 8213034705 100.0 100.0 2.951285 2.951285 gladimacowgirl Gladimacowgirl 58 58 95.0 95.0 117.5 117.5
3 3 8213034705 8213034705 117.5 117.5 2.998947 2.998947 daysrus Dayrus 10 10 95.0 95.0 117.5 117.5
4 4 8213060420 8213060420 2.0 2.0 0.065266 0.065266 donnie4814 唐妮4814 5 5 1.0 1.0 120.0 120.0

As you can see, each row of our data set concerns a single bid on a specific eBay Xbox auction. Here is a brief description of each column:

如您所见,我们数据集的每一行都涉及特定eBay Xbox拍卖的一次出价。 这是每列的简要说明:

  • auctionid – A unique identifier of each auction.
  • bid – The value of the bid.
  • bidtime – The age of the auction, in days, at the time of the bid.
  • bidder – eBay username of the bidder.
  • bidderrate – The bidder’s eBay user rating.
  • openbid – The opening bid set by the seller for the auction.
  • price – The winning bid at the close of the auction.
  • auctionid –每个拍卖的唯一标识符。
  • bidbid的价值。
  • bidtime –投标时的拍卖期限(天)。
  • bidderbidder eBay用户名。
  • bidderrate –出价人的eBay用户评分。
  • openbid –卖方为拍卖设置的开标价。
  • price –拍卖结束时的中标价。

什么是SettingWithCopyWarning? (What is SettingWithCopyWarning?)

The first thing to understand is that SettingWithCopyWarning is a warning, and not an error.

首先要了解的是SettingWithCopyWarning是警告,而不是错误。

While an error indicates that something is broken, such as invalid syntax or an attempt to reference an undefined variable, the job of a warning is to alert the programmer to potential bugs or issues with their code that are still permitted operations within the language. In this case, the warning very likely indicates a serious but inconspicuous mistake.

虽然错误表明发生了某些故障,例如无效的语法或试图引用未定义的变量,但警告的任务是警告程序员潜在的错误或代码问题,这些错误或问题仍是该语言允许的操作。 在这种情况下,警告很可能表示严重但不起眼的错误。

SettingWithCopyWarning informs you that your operation might not have worked as expected and that you should check the result to make sure you haven’t made a mistake.

SettingWithCopyWarning通知您,您的操作可能未达到预期的效果,因此应检查结果以确保您没有SettingWithCopyWarning

It can be tempting to ignore the warning if your code still works as expected. This is bad practice and SettingWithCopyWarning should never be ignored. Take some time to understand why you are getting the warning before taking action.

如果您的代码仍按预期运行,可能会忽略该警告。 这是一种不好的做法, SettingWithCopyWarning 绝不应忽略。 请花一些时间来了解为什么要采取警告后才收到警告。

To understand what SettingWithCopyWarning is about, it’s helpful to understand that some actions in pandas can return a view of your data, and others will return a copy.

要了解SettingWithCopyWarning ,了解熊猫中的某些操作可以返回数据视图而其他操作将返回副本是有帮助的。

As you can see above, the view df2 on the left is just a subset of the original df1, whereas the copy on the right creates a new, unique object df2.

如上所示,左侧的视图df2只是原始df1的子集,而右侧的副本创建了一个新的唯一对象df2

This potentially causes problem when we try to make changes:

当我们尝试进行更改时,这可能会导致问题:

Depending on what we’re doing we might want to be modifying the original df1 (left), or we might want to be modifying only df2 (right). The warning is letting us know that our code may have done one, when we want it to have done the other.

根据我们正在执行的操作,我们可能想修改原始的df1 (左),或者我们可能只想修改df2 (右)。 警告是让我们知道我们的代码可能已经完成了另一件事。

We’ll look at this in depth later, but for now let’s get to grips with the two main causes of the warning and how to fix them.

稍后我们将对此进行深入研究,但现在让我们来了解警告的两个主要原因以及如何解决它们。

连锁分配 (Chained assignment)

Pandas generates the warning when it detects something called chained assignment. Let’s define a few terms we’ll be using to explain things:

熊猫检测到称为链式分配的东西时会生成警告。 让我们定义一些我们将用来解释事物的术语:

  • Assignment – Operations that set the value of something, for example data = pd.read_csv('xbox-3-day-auctions.csv'). Often referred to as a set.
  • Access – Operations that return the value of something, such as the below examples of indexing and chaining. Often referred to as a get.
  • Indexing – Any assignment or access method that references a subset of the data; for example data[1:5].
  • Chaining – The use of more than one indexing operation back-to-back; for example data[1:5][1:3].
  • 赋值–设置值的操作,例如data = pd.read_csv('xbox-3-day-auctions.csv') 。 通常称为集合
  • 访问–返回某物价值的操作,例如下面的索引和链接示例。 通常称为get
  • 索引–引用数据子集的任何分配或访问方法; 例如data[1:5]
  • 链接–背对背使用多个索引操作; 例如data[1:5][1:3]

Chained assignment is the combination of chaining and assignment. Let’s take a quick look at an example with the data set we loaded earlier. We will go over this in more detail later on. For the sake of this example, let’s say that we have been told that the user 'parakeet2004'’s bidder rating is incorrect and we must update it. Let’s start by looking at the current values.

链接分配是链接和分配的组合。 让我们快速看一下我们之前加载的数据集的示例。 稍后我们将更详细地介绍这一点。 出于这个示例的原因,假设我们被告知用户'parakeet2004' '的竞标者评级不正确,我们必须对其进行更新。 让我们从查看当前值开始。

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱
6 6 8213060420 8213060420 3.00 3.00 0.186539 0.186539 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0
7 7 8213060420 8213060420 10.00 10.00 0.186690 0.186690 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0
8 8 8213060420 8213060420 24.99 24.99 0.187049 0.187049 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0

We have three rows to update the bidderrate field on; let’s go ahead and do that.

我们有三行用来更新bidderrate字段; 让我们继续做。

datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ][][ 'bidderrate''bidderrate' ] ] = = 100
100


/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipykernel/__main__.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value insteadSee the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyif __name__ == '__main__':

Oh no! We’ve mysteriously stumbled upon the SettingWithCopyWarning!

不好了! 我们神秘地偶然发现了SettingWithCopyWarning

If we take a look, we can see that in this case the values were not changed:

如果我们看一下,可以看到在这种情况下,值没有更改:

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱
6 6 8213060420 8213060420 3.00 3.00 0.186539 0.186539 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0
7 7 8213060420 8213060420 10.00 10.00 0.186690 0.186690 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0
8 8 8213060420 8213060420 24.99 24.99 0.187049 0.187049 parakeet2004 parakeet2004 5 5 1.0 1.0 120.0 120.0

The warning was generated because we have chained two indexing operations together. This is made easier to spot because we’ve used square brackets twice, but the same would be true if we used other access methods such as .bidderrate, .loc[], .iloc[], .ix[] and so on. Our chained operations are:

产生警告是因为我们将两个索引操作链接在一起。 由于使用了两次方括号,因此更易于发现,但是如果使用其他访问方法(例如.bidderrate.loc[] .iloc[] .ix[].iloc[].ix[]如此。 我们的连锁经营是:

  • data[data.bidder == 'parakeet2004']
  • ['bidderrate'] = 100
  • data[data.bidder == 'parakeet2004']
  • ['bidderrate'] = 100

These two chained operations execute independently, one after another. The first is an access method (get operation), that will return a DataFrame containing all rows where bidder equals 'parakeet2004'. The second is an assignment operation (set operation), that is called on this new DataFrame. We are not operating on the original DataFrame at all.

这两个链接的操作彼此独立地执行。 第一种是访问方法(GET操作),将返回一个DataFrame包含所有行bidder平等'parakeet2004' 。 第二个是赋值操作(设置操作),在此新DataFrameDataFrame 。 我们根本没有对原始DataFrame进行操作。

The solution is simple: combine the chained operations into a single operation using loc so that pandas can ensure the original DataFrame is set. Pandas will always ensure that unchained set operations, like the below, work.

解决方案很简单:使用loc将链接的操作组合为单个操作,以便熊猫可以确保设置了原始DataFrame 。 熊猫将始终确保未绑定的设置操作(如下所示)正常工作。

# Setting the new value
# Setting the new value
datadata .. locloc [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' , , 'bidderrate''bidderrate' ] ] = = 100100# Taking a look at the result
# Taking a look at the result
datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ][][ 'bidderrate''bidderrate' ]
]


6    100
7    100
8    100
Name: bidderrate, dtype: int64

This is what the warning suggests we do, and it works perfectly in this case.

这就是警告所建议的,并且在这种情况下可以很好地工作。

隐藏链接 (Hidden chaining)

Moving on to the second most common way people encounter SettingWithCopyWarning. Let’s investigate winning bids. We will create a new dataframe to work with them, taking care to use loc going forward now that we have learned our lesson about chained assignment.

转到人们遇到SettingWithCopyWarning的第二种最常见的方式。 让我们调查中标。 我们将创建一个新的数据框以与它们一起使用,既然我们已经了解了有关链式分配的课程,请谨慎使用loc

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱
3 3 8213034705 8213034705 117.5 117.5 2.998947 2.998947 daysrus Dayrus 10 10 95.00 95.00 117.5 117.5
25 25 8213060420 8213060420 120.0 120.0 2.999722 2.999722 djnoeproductions djnoeproductions 17 17 1.00 1.00 120.0 120.0
44 44 8213067838 8213067838 132.5 132.5 2.996632 2.996632 *champaignbubbles* *香槟泡泡* 202 202 29.99 29.99 132.5 132.5
45 45 8213067838 8213067838 132.5 132.5 2.997789 2.997789 *champaignbubbles* *香槟泡泡* 202 202 29.99 29.99 132.5 132.5
66 66 8213073509 8213073509 114.5 114.5 2.999236 2.999236 rr6kids rr6kids 4 4 1.00 1.00 114.5 114.5

We might write several subsequent lines of code working with our winners variable.

我们可能会使用赢家变量编写随后的几行代码。

mean_win_time mean_win_time = = winnerswinners .. bidtimebidtime .. meanmean ()
()
... ... # 20 lines of code
# 20 lines of code
mode_open_bid mode_open_bid = = winnerswinners .. openbidopenbid .. modemode ()
()

By chance, we come across another mistake in our DataFrame. This time the bidder value is missing from the row labelled 304.

一次偶然的机会,我们在DataFrame遇到了另一个错误。 这次,标有304的行中缺少bidder值。

For the sake of our example, let’s say that we know the true username of this bidder and update our data.

就我们的示例而言,假设我们知道该竞标者的真实用户名并更新了我们的数据。

winnerswinners .. locloc [[ 304304 , , 'bidder''bidder' ] ] = = 'therealname'
'therealname'


/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pandas/core/indexing.py:517: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value insteadSee the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyself.obj[item] = s

Another SettingWithCopyWarning! But we used loc, how has this happened again? To investigate, let’s take a look at the result of our code:

另一个SettingWithCopyWarning ! 但是我们使用loc ,这又是怎么回事? 为了进行调查,让我们看一下代码的结果:


therealname

It worked this time, so why did we get the warning?

这次有效了,那么我们为什么收到警告?

Chained indexing can occur across two lines as well as within one. Because winners was created as the output of a get operation (data.loc[data.bid == data.price]), it might be a copy of the original DataFrame or it might not be, but until we checked there was no way to know! When we indexed winners, we were actually using chained indexing.

链接索引可以在两行之间以及在同一行内发生。 因为winners是作为get操作的输出创建的( data.loc[data.bid == data.price] ),所以它可能是原始DataFrame的副本,也可能不是,但是直到我们检查DataFrame为止要知道! 当我们为winners建立索引时,实际上是在使用链式索引。

This means that we may have also modified data as well when we were trying to modify winners.

这意味着,当我们尝试修改winners时,我们也可能已经修改了data

In a real codebase, these lines could occur very far apart so tracking down the source of the problem might be more difficult, but the situation is the same.

在实际的代码库中,这些行可能会相距很远,因此跟踪问题的根源可能会更加困难,但是情况是一样的。

To prevent the warning in this case, the solution is to explicitly tell pandas to make a copy when we create the new dataframe:

为了避免这种情况下的警告,解决方案是在创建新数据框时明确告诉熊猫进行复制:

winners winners = = datadata .. locloc [[ datadata .. bid bid == == datadata .. priceprice ]] .. copycopy ()
()
winnerswinners .. locloc [[ 304304 , , 'bidder''bidder' ] ] = = 'therealname'
'therealname'
printprint (( winnerswinners .. locloc [[ 304304 , , 'bidder''bidder' ])
])
printprint (( datadata .. locloc [[ 304304 , , 'bidder''bidder' ])
])


therealname
nan

And that’s it! It’s that simple.

就是这样! 就这么简单。

The trick is to learn to identify chained indexing and avoid it at all costs. If you want to change the original, use a single assignment operation. If you want a copy, make sure you force pandas to do just that. This will save time and make your code water-tight.

诀窍是学会识别链接索引并不惜一切代价避免索引。 如果要更改原稿,请使用一次分配操作。 如果要复制,请确保您强迫熊猫这样做。 这将节省时间,并使您的代码不漏水。

Also note that even though the SettingWithCopyWarning will only occur when you are setting, it’s best to avoid chained indexing for gets too. Chained operations are slower and will cause problems if you decide to add assignment operations later on.

还要注意,即使SettingWithCopyWarning仅在设置时才会发生,但最好还是避免获取链式索引。 链式操作较慢,如果您以后决定添加分配操作,则会导致问题。

处理SettingWithCopyWarning的提示和技巧 (Tips and tricks for dealing with SettingWithCopyWarning)

Before we do a much more in-depth analysis down below, let’s pull out the microscope and take a look at some of the finer points and nitty-gritty details of the SettingWithCopyWarning.

在下面进行更深入的分析之前,让我们拉出显微镜,看看SettingWithCopyWarning一些细微细节。

关闭警告 (Turning off the warning)

First off, this article would never be complete without discussing how to explicitly control the SettingWithCopy settings. The pandas mode.chained_assignment option can take one of the values:

首先,如果不讨论如何显式控制SettingWithCopy设置,本文将永远是不完整的。 pandas mode.chained_assignment选项可以采用以下值之一:

  • 'raise' – to raise an exception instead of a warning.
  • 'warn' – to generate a warning (default).
  • None – to switch off the warning entirely.
  • 'raise'引发异常而不是警告。
  • 'warn' –生成警告(默认)。
  • None -完全关闭警告。

For example, let’s switch off the warning:

例如,让我们关闭警告:

Because this gives us no warning whatsoever, it’s not recommended unless you have a full grasp of what you are doing. If you feel even the tiniest inkling of doubt, this isn’t advised. Some developers take SettingWithCopy very seriously and choose to elevate it to an exception instead, like so:

因为这不会给我们任何警告,所以除非您完全了解自己的操作,否则不建议这样做。 如果您甚至对怀疑的怀疑微不足道,则不建议这样做。 一些开发人员非常重视SettingWithCopy选择将其提升为异常,例如:

pdpd .. set_optionset_option (( 'mode.chained_assignment''mode.chained_assignment' , , 'raise''raise' )
)
datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ][][ 'bidderrate''bidderrate' ] ] = = 100
100

This can be especially useful if you’re working on a project with inexperienced pandas developers on your team, or a project that requires a high level of rigor or certainty in its integrity.

如果您正在与团队中缺乏经验的熊猫开发人员一起进行的项目,或者在完整性方面要求很高的严格性或确定性的项目,则此功能特别有用。

A more precise way to use this setting is by using a context manager.

使用此设置的更精确方法是使用上下文管理器 。

# resets the option we set in the previous code segment
# resets the option we set in the previous code segment
pdpd .. reset_optionreset_option (( 'mode.chained_assignment''mode.chained_assignment' ))with with pdpd .. option_contextoption_context (( 'mode.chained_assignment''mode.chained_assignment' , , NoneNone ):):datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ][][ 'bidderrate''bidderrate' ] ] = = 100
100

As you can see, this approach enables fine-grained warning suppression, rather than indiscriminately affecting the entire environment.

如您所见,此方法可实现细粒度的警告抑制,而不是不加选择地影响整个环境。

is_copy属性 (The is_copy property)

Another trick that can be used to avoid the warning, is to modify one of the tools pandas uses to interpret a SettingWithCopy scenario. Each DataFrame has an is_copy property that is None by default but uses a weakref to reference the source DataFrame if it’s a copy. By setting is_copy to None, you can avoid generating a warning.

可以避免警告使用的另一种技巧是修改熊猫用来解释SettingWithCopy方案的工具之一。 每个DataFrame都有一个is_copy属性,默认情况下为None ,但是如果它是副本,则使用weakref引用源DataFrame 。 通过将is_copy设置为None ,可以避免生成警告。

However, note this will not miraculously solve the problem, but it does make bug detection potentially very difficult.

但是,请注意,这不会奇迹般地解决问题,但确实会使错误检测变得非常困难。

单类型对象与多类型对象 (Single vs multi-dtyped objects)

A further point that is worth stressing is the distinction between single-dtyped and multi-dtyped objects. A DataFrame is single-dtyped if all its columns are of the same dtype; for example:

值得强调的另一点是单类型对象与多类型对象之间的区别。 如果DataFrame所有列都属于同一DataFrame则为Single-dtyped。 例如:

import import numpy numpy as as npnpsingle_dtype_df single_dtype_df = = pdpd .. DataFrameDataFrame (( npnp .. randomrandom .. randrand (( 55 ,, 22 ), ), columnscolumns == listlist (( 'AB''AB' ))
))
printprint (( single_dtype_dfsingle_dtype_df .. dtypesdtypes )
)
single_dtype_df
single_dtype_df


A    float64
B    float64
dtype: object

A 一个 B
0 0 0.383197 0.383197 0.895652 0.895652
1 1个 0.077943 0.077943 0.905245 0.905245
2 2 0.452151 0.452151 0.677482 0.677482
3 3 0.533288 0.533288 0.768252 0.768252
4 4 0.389799 0.389799 0.674594 0.674594

Whereas a DataFrame is multi-dtyped if its columns do not all have the same dtype, such as:

DataFrame是多dtyped如果列不都具有相同的D型,如:


A    float64
B     object
dtype: object

A 一个 B
0 0 0.615487 0.615487 a 一个
1 1个 0.946149 0.946149 b b
2 2 0.701231 0.701231 c C
3 3 0.756522 0.756522 d d
4 4 0.481719 0.481719 e Ë

For reasons explained in the History section below, an indexer-get operation on a multi-dtyped object will always return a copy. However, mainly for efficiency, an indexer get operation on a single-dtyped object almost always returns a view; the caveat here being that this depends on the memory layout of the object and is not guaranteed.

出于下面“历史记录”部分中说明的原因,对多类型对象的indexer-get操作将始终返回副本。 但是,主要是为了提高效率,对单类型对象的索引器get操作几乎总是返回视图。 需要注意的是,这取决于对象的内存布局,因此不能保证。

误报 (False positives)

False positives, or situations where chained assignment is inadvertently reported, used to be more common in earlier versions of pandas but have since been mostly ironed out. For completeness, it’s useful to include some examples here of fixed false positives. If you experience any of the situations below with earlier versions of pandas, then the warning can safely be ignored or suppressed (or avoided altogether by upgrading!)

在早期版本的熊猫中,误报或无意间报告连锁分配的情况曾经很普遍,但此后大部分被消除。 为了完整起见,在此处包含一些固定误报的示例非常有用。 如果您在使用较早版本的熊猫时遇到以下任何情况,则可以安全地忽略或消除该警告(或通过升级完全避免!)

Adding a new column to a DataFrame using a current column’s values used to generate a warning, but this has been fixed.

使用用于生成警告的当前列的值向DataFrame添加新列,但此问题已得到解决。

datadata [[ 'bidtime_hours''bidtime_hours' ] ] = = datadata .. bidtimebidtime .. mapmap (( lambda lambda xx : : x x * * 2424 )
)
datadata .. headhead (( 22 )
)

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱 bidtime_hours bidtime_hours
0 0 8213034705 8213034705 95.0 95.0 2.927373 2.927373 jake7870 jake7870 0 0 95.0 95.0 117.5 117.5 70.256952 70.256952
1 1个 8213034705 8213034705 115.0 115.0 2.943484 2.943484 davidbresler2 davidbresler2 1 1个 95.0 95.0 117.5 117.5 70.643616 70.643616

Until recently, a false positive also occurred when setting using the apply method on a slice of a DataFrame, although this too has been fixed.

直到最近,当使用apply方法在DataFrame的切片上进行设​​置时, 也会出现 DataFrame ,尽管这一问题也已得到解决。

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱 bidtime_hours bidtime_hours
0 0 8213034705 8213034705 95.0 95.0 2.927373 2.927373 jake7870 jake7870 0 0 95.0 95.0 117.5 117.5 70.256952 70.256952
1 1个 8213034705 8213034705 115.0 115.0 2.943484 2.943484 davidbresler2 davidbresler2 1 1个 95.0 95.0 117.5 117.5 70.643616 70.643616

And finally, until version 0.17.0, there was a bug in the DataFrame.sample method that caused spurious SettingWithCopy warnings. The sample method now returns a copy every time.

最后,直到0.17.0版, DataFrame.sample方法中存在一个错误,该错误导致了虚假的SettingWithCopy警告。 现在, sample方法每次都返回一个副本。

sample sample = = datadata .. samplesample (( 22 )
)
samplesample .. locloc [:, [:, 'price''price' ] ] = = 120
120
samplesample .. headhead ()
()

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱 bidtime_hours bidtime_hours
481 481 8215408023 8215408023 91.01 91.01 2.990741 2.990741 sailer4eva sailer4eva 1 1个 0.99 0.99 120 120 71.777784 71.777784
503 503 8215571039 8215571039 100.00 100.00 1.965463 1.965463 lambonius1 lambonius1 0 0 50.00 50.00 120 120 47.171112 47.171112

深度链接 (Chained assignment in Depth)

Let’s reuse our earlier example where we were trying to update the bidderrate column for each row in data with a bidder value of 'parakeet2004'.

让我们再次使用我们前面的例子,我们试图更新bidderrate中的每一行的列databidder的价值'parakeet2004'


/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ipykernel/__main__.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value insteadSee the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyif __name__ == '__main__':

What pandas is really telling us with this SettingWithCopyWarning is that the behavior of our code is ambiguous, but to understand why this is and the wording of the warning, it will be helpful to go over a few concepts.

大熊猫通过此SettingWithCopyWarning真正告诉我们的是,我们的代码的行为是模棱两可的,但是要了解为什么这样做以及警告的措词,请SettingWithCopyWarning一些概念。

We talked briefly about views and copies earlier. There are two possible ways to access a subset of a DataFrame: either one could create a reference to the original data in memory (a view) or copy the subset into a new, smaller DataFrame (a copy). A view is a way of looking at a particular portion the original data, whereas a copy is a clone of that data to a new location in memory. As our diagram earlier showed, modifying a view will modify the original variable but modifying a copy will not.

前面我们简要讨论了视图和副本。 有两种方法可以访问DataFrame的子集:一种可以创建对内存中原始数据的引用(视图),也可以将子集复制到一个新的,较小的DataFrame (副本)。 视图是查看原始数据特定部分的一种方式,而副本是该数据到内存中新位置的克隆 。 如我们前面的图所示,修改视图将修改原始变量,而修改副本则不会。

For reasons that we will get into later, the output of ‘get’ operations in pandas is not guaranteed. Either a view or a copy could be returned when you index a pandas data structure, which means get operations on a DataFrame return a new DataFrame that can contain either:

出于稍后将要讨论的原因,不能保证在熊猫中输出“ get”操作。 对熊猫数据结构建立索引时,可能会返回视图或副本,这意味着对DataFrame get操作将返回一个新的DataFrame ,其中可以包含以下任一内容:

  • A copy of data from the original object.
  • A reference to the original object’s data without making a copy.
  • 来自原始对象的数据副本。
  • 引用原始对象的数据但不进行复制。

Because we don’t know what will happen and each possibility has very different behavior, ignoring the warning is playing with fire.

因为我们不知道会发生什么,并且每种可能性的行为都非常不同,所以忽略警告就是在玩火。

To illustrate views, copies and this ambiguity more clearly, let’s create a simple DataFrame and index it:

为了更清楚地说明视图,副本和这种歧义,让我们创建一个简单的DataFrame并为其建立索引:

df1 df1 = = pdpd .. DataFrameDataFrame (( npnp .. arangearange (( 66 )) .. reshapereshape (((( 33 ,, 22 )), )), columnscolumns == listlist (( 'AB''AB' ))
))
df1
df1

A 一个 B
0 0 0 0 1 1个
1 1个 2 2 3 3
2 2 4 4 5 5

And let’s assign a subset of df1 to df2:

然后将df1的子集分配给df2

A 一个 B
0 0 0 0 1 1个
1 1个 2 2 3 3

Given what we have learned, we know that df2 could be a view on df1 or a copy of a subset of df1.

鉴于我们学到了什么,我们知道, df2可以在视图上df1或子集的副本df1

Before we can get to grips with our problem, we also need to take another look at chained indexing. Expanding on our example with 'parakeet2004', we have chained together two indexing operations:

在解决问题之前,我们还需要再看一下链接索引。 在使用'parakeet2004'扩展示例时,我们将两个索引操作链接在一起:

datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ]
]
__intermediate____intermediate__ [[ 'bidderrate''bidderrate' ] ] = = 100
100

Where __intermediate__ represents the output of the first call and is completely hidden from us. Remember that we would get the same problematic outcome if we had used attribute access:

其中__intermediate__代表第一个调用的输出,对我们完全隐藏了。 请记住,如果使用属性访问,也会得到同样有问题的结果:

The same applies to any other form of chained call because we are generating this intermediate object.

这同样适用于任何其他形式的链接调用, 因为我们正在生成此中间对象

Under the hood, chained indexing means making more than one call to __getitem__ or __setitem__ to accomplish a single operation. These are special Python methods that are invoked by the use of square brackets on an instance of a class that implements them, an example of what is called syntactic sugar. Let’s look at what the Python interpreter will execute in our example.

在后台,链接索引意味着多次调用__getitem____setitem__来完成一个操作。 这些是特殊的Python方法 ,通过在实现它们的类的实例上使用方括号(称为语法糖的示例)来调用它们。 让我们看看示例中Python解释器将执行什么。

# Our code
# Our code
datadata [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' ][][ 'bidderrate''bidderrate' ] ] = = 100100# Code executed
# Code executed
datadata .. __getitem____getitem__ (( datadata .. __getitem____getitem__ (( 'bidder''bidder' ) ) == == 'parakeet2004''parakeet2004' )) .. __setitem____setitem__ (( 'bidderrate''bidderrate' , , 100100 )
)

As you may have realized already, SettingWithCopyWarning is generated as a result of this chained __setitem__ call. You can try this for yourself – the lines above function identically. For clarity, note that the second __getitem__ call (for the bidder column) is nested and not at all part of the chaining problem here.

您可能已经意识到,此__setitem__链接调用生成了SettingWithCopyWarning 。 您可以自己尝试–上面的行功能相同。 为了清楚起见,请注意,第二个__getitem__调用(用于bidder列)是嵌套的,而不是这里所有链接问题的一部分。

In general, as discussed, pandas does not guarantee whether a get operation will return a view or a copy of the data. If a view is returned in our example, the second expression in our chained assignment will be a call to __setitem__ on the original object. But, if a copy is returned, it’s the copy that will be modified instead – the original object does not get modified.

通常,如上所述,pandas不保证get操作将返回数据的视图还是副本。 如果在我们的示例中返回视图,则链式分配中的第二个表达式将是对原始对象的__setitem__的调用。 但是,如果返回副本,则将修改该副本–原始对象不会被修改。

This is what the warning means by “a value is trying to be set on a copy of a slice from a DataFrame”. As there are no references to this copy, it will ultimately be garbage collected. The SettingWithCopyWarning is letting us know that pandas cannot determine whether a view or a copy was returned by the first __getitem__ call, and so it’s unclear whether the assignment changed the original object or not. Another way to think about why pandas gives us this warning is because the answer to the question “are we modifying the original?” is unknown.

这就是警告的意思,“试图在DataFrame的切片副本上设置一个值”。 由于没有对此副本的引用,因此最终将对其进行垃圾回收 。 SettingWithCopyWarning可以让我们知道熊猫无法确定第一个__getitem__调用是否返回了视图或副本,因此不清楚赋值是否更改了原始对象。 思考熊猫为什么会向我们发出此警告的另一种方式是,因为对“我们是否正在修改原始照片?”这一问题的回答 未知。

We do want to modify the original, and the solution that the warning suggests is to convert these two separate, chained operations into a single assignment operation using loc. This will remove chained indexing from our code and we will no longer receive the warning. Our fixed code and its expanded version will look like this:

我们确实要修改原始文件,警告建议的解决方案是使用loc将这两个单独的链接操作转换为单个赋值操作。 这将从我们的代码中删除链接索引,并且我们将不再收到警告。 我们的固定代码及其扩展版本将如下所示:

Our DataFrame’s loc property is guaranteed to be the original DataFrame itself but with expanded indexing capabilities.

我们的DataFrame的loc属性保证是原始DataFrame本身,但具有扩展的索引功能。

假阴性 (False negatives)

Using loc doesn’t end our problems because get operations with loc can still return either a view or a copy. Let’s quickly examine a somewhat convoluted example.

使用loc并没有结束我们的问题,因为用GET操作loc仍然可以返回一个视图或复印件。 让我们快速研究一个复杂的例子。

datadata .. locloc [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' , , (( 'bidderrate''bidderrate' , , 'bid''bid' )]
)]

bidderrate 投标价 bid 出价
6 6 100 100 3.00 3.00
7 7 100 100 10.00 10.00
8 8 100 100 24.99 24.99

We’ve pulled two columns out this time rather than just the one. Let’s try to set all the bid values.

这次我们抽出了两列,而不仅仅是一列。 让我们尝试将所有的bid值。

bidderrate 投标价 bid 出价
6 6 100 100 3.00 3.00
7 7 100 100 10.00 10.00
8 8 100 100 24.99 24.99

No effect and no warning! We have set a value on a copy of a slice but it was not detected by pandas – this is a false negative. Just because we have used loc doesn’t mean we can start using chained assignment again. There is an old, unresolved issue on GitHub for this particular bug.

没有效果,没有警告! 我们在切片的副本上设置了一个值,但熊猫没有检测到该值–这是一个假阴性。 仅仅因为我们使用过loc并不意味着我们可以再次开始使用链式分配。 GitHub上有一个针对此特定错误的旧问题 ,尚未解决。

The correct way to do this is as follows:

正确的方法如下:

datadata .. locloc [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' , , 'bid''bid' ] ] = = 5.0
5.0
datadata .. locloc [[ datadata .. bidder bidder == == 'parakeet2004''parakeet2004' , , (( 'bidderrate''bidderrate' , , 'bid''bid' )]
)]

bidderrate 投标价 bid 出价
6 6 100 100 5.0 5.0
7 7 100 100 5.0 5.0
8 8 100 100 5.0 5.0

You might wonder how someone could possibly end up with such a problem in practice, but it’s easier than you might expect when assigning the results of DataFrame queries to variables as we do in the next section.

您可能想知道在实践中某人可能最终会遇到这样的问题,但是将DataFrame查询的结果分配给变量时,这比您预期的要容易,就像我们在下一节中所做的那样。

隐藏链接 (Hidden chaining)

Let’s look again at our hidden chaining example from earlier, where we were trying to set the bidder value from the row labelled 304 in our winners variable.

让我们再次看一下之前的隐藏链接示例,在该示例中,我们试图从winners变量中标有304的行中设置bidder值。


/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pandas/core/indexing.py:517: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value insteadSee the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyself.obj[item] = s

We get another SettingWithCopyWarning even though we used loc. This problem can be incredibly confusing as the warning message appears to be suggesting that we do what we have already done.

即使使用loc我们也会得到另一个SettingWithCopyWarning 。 由于警告消息似乎表明我们在做我们已经做过的事情,所以这个问题可能会令人困惑。

But think about the winners variable. What really is it? Given that we instantiated it via data.loc[data.bid == data.price], we cannot know whether it’s a view or a copy of our original data DataFrame (because get operations return either a view or a copy). Combining the instantiation with the line that generated the warning makes clear our mistake.

但是考虑winners变量。 到底是什么 鉴于我们是通过data.loc[data.bid == data.price]实例化的,因此我们不知道它是视图还是原始data DataFrame的副本(因为get操作返回视图或副本)。 将实例化与生成警告的行结合起来可以明确我们的错误。

datadata .. locloc [[ datadata .. bid bid == == datadata .. priceprice ]] .. locloc [[ 304304 , , 'bidder''bidder' ] ] = = 'therealname'
'therealname'


/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pandas/core/indexing.py:517: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value insteadSee the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copyself.obj[item] = s

We used chained assignment again, but this time it was broken across two lines. Another way to think about this is to ask the question “does this modify one or two things?” In our case, the answer is unknown: if winners is a copy then only winners is affected but if it’s a view both winners and data will show updated values. This situation can occur between lines that are very far apart within a script or codebase, making the source of the problem potentially very difficult to track down.

我们再次使用了链式分配,但是这次跨了两行。 对此进行思考的另一种方式是问一个问题:“这会修改一两个东西吗?” 在我们的案例中,答案是未知的:如果winners是副本,则仅获winners会受到影响,但如果是视图,则winnersdata都将显示更新的值。 在脚本或代码库中相距很远的行之间可能会发生这种情况,从而可能很难找到问题的根源。

The intention of the warning here to prevent us from thinking our code will modify the original DataFrame when it won’t, or that we’re modifying a copy rather than the original. Delving into old issues on pandas’ GitHub repo, you can read the devs explaining this themselves.

警告的目的是防止我们认为我们的代码将在不修改原始DataFrame时修改它,或者我们在修改副本而不是原始内容。 深入研究熊猫的GitHub存储库中的旧问题,您可以阅读开发人员自己解释的内容。

How we resolve this problem depends very much on our own intentions. If we are happy to work with a copy of our original data, the solution is simply to force pandas to make a copy.

我们如何解决这个问题在很大程度上取决于我们自己的意图。 如果我们乐于使用原始数据的副本,则解决方案就是强制熊猫制作副本。


nan
therealname

If, on the other hand, you require that the original DataFrame is updated then you should work with the original DataFrame instead of instantiating other variables with unknown behavior. Our prior code would become:

另一方面,如果您要求更新原始DataFrame ,则应该使用原始DataFrame而不是实例化具有未知行为的其他变量。 我们之前的代码将变为:

# Finding the winners
# Finding the winners
winner_mask winner_mask = = datadata .. bid bid == == datadata .. priceprice# Taking a peek
# Taking a peek
datadata .. locloc [[ winner_maskwinner_mask ]] .. headhead ()()# Doing analysis
# Doing analysis
mean_win_time mean_win_time = = datadata .. locloc [[ winner_maskwinner_mask , , 'bidtime''bidtime' ]] .. meanmean ()
()
... ... # 20 lines of code
# 20 lines of code
mode_open_bid mode_open_bid = = datadata .. locloc [[ winner_maskwinner_mask , , 'openbid''openbid' ]] .. modemode ()()# Updating the username
# Updating the username
datadata .. locloc [[ 304304 , , 'bidder''bidder' ] ] = = 'therealname'
'therealname'

In more complex circumstances, such as modifying a subset of a subset of a DataFrame, instead of using chained indexing one can modify the slices one is making via loc on the original DataFrame. For example, you could change our new winner_mask variable above or create a new variable that selected a subset of winners, like so:

在更复杂的情况下,例如修改DataFrame子集的一个子集,而不是使用链接索引,可以修改通过loc在原始DataFrame上进行的DataFrame 。 例如,您可以在上方更改新的winner_mask变量,或创建一个选择了一部分获奖者的新变量,如下所示:

auctionid 拍卖编号 bid 出价 bidtime 竞标时间 bidder 投标人 bidderrate 投标价 openbid 公开竞标 price 价钱 bidtime_hours bidtime_hours
225 225 8213387444 8213387444 152.0 152.0 2.919757 2.919757 uconnbabydoll1975 1975年 15 15 0.99 0.99 152.0 152.0 70.074168 70.074168
328 328 8213935134 8213935134 207.5 207.5 2.983542 2.983542 toby2492 toby2492 0 0 0.10 0.10 207.5 207.5 71.605008 71.605008
416 416 8214430396 8214430396 199.0 199.0 2.990463 2.990463 volpendesta Volpendesta 4 4 9.99 9.99 199.0 199.0 71.771112 71.771112
531 531 8215582227 8215582227 152.5 152.5 2.999664 2.999664 ultimatum_man 最后通man 2 2 60.00 60.00 152.5 152.5 71.991936 71.991936

This technique is more robust to future codebase maintenance and scaling.

该技术对将来的代码库维护和扩展更加健壮。

历史 (History)

You might be wondering why the whole SettingWithCopy problem can’t simply be avoided entirely by explicitly specifying indexing methods that return either a view or a copy rather than creating the confusing situation we find ourselves in. To understand this, we must look into pandas’ past.

您可能想知道为什么SettingWithCopy明确指定返回视图或副本的索引方法而不是创建我们发现的令人困惑的情况来简单地完全避免整个SettingWithCopy问题。要理解这一点,我们必须研究熊猫过去。

The logic pandas uses to determine whether it returns a view or a copy stems from its use of the NumPy library, which underlies pandas’ operation. Views actually entered the pandas lexicon via NumPy. Indeed, views are useful in NumPy because they are returned predictably. Because NumPy arrays are single-typed, pandas attempts to minimize space and processing requirements by using the most appropriate dtype. As a result, slices of a DataFrame that contain a single dtype can be returned as a view on a single NumPy array, which is a highly efficient way to handle the operation. However, multi-dtype slices can’t be stored in the same way in NumPy so efficiently. Pandas juggles versatile indexing functionality with the ability to use its NumPy core most effectively.

熊猫使用的逻辑是确定其返回视图还是副本的原因是使用了NumPy库,该库是熊猫操作的基础。 观看次数实际上是通过NumPy进入大熊猫词典的。 实际上,视图在NumPy中很有用,因为它们是可预测地返回的。 由于NumPy数组是单类型的,因此pandas尝试通过使用最合适的dtype来最小化空间和处理要求。 结果,可以将包含单个DataFrame切片作为单个NumPy数组上的视图返回,这是处理该操作的一种高效方法。 但是,无法以相同的方式将多dtype切片有效地存储在NumPy中。 熊猫利用最有效地使用其NumPy核心的功能,充分利用了多种索引功能。

Ultimately, indexing in pandas was designed to be useful and versatile in a way that doesn’t exactly marry the functionality of the underlying NumPy arrays at its core. The interaction between these elements of design and function over time has led to a complex set of rules that determine whether or not a view or a copy can be returned. Experienced pandas developers are generally happy with pandas’ behaviors because they are comfortable l navigating its indexing behaviors.

最终,熊猫索引被设计为有用且通用的,其方式与核心NumPy数组的功能完全不符。 随着时间的流逝,设计和功能的这些元素之间的相互作用导致了一套复杂的规则,这些规则决定了是否可以返回视图或副本。 经验丰富的熊猫开发人员通常会对熊猫的行为感到满意,因为他们乐于浏览其索引行为。

Unfortunately for newcomers to the library, chained indexing is almost unavoidable despite not being the intended approach simply because get operations return indexable pandas objects. Furthermore, in the words of Jeff Reback, one of the core developers of pandas for several years, “It’s simply not possible from a language perspective to detect chain indexing directly; it has to be inferred”.

不幸的是,对于刚进入图书馆的新手来说,尽管不是因为预期的方法而导致链式索引几乎是不可避免的,这仅仅是因为get操作返回可索引的pandas对象。 而且, 用几年来熊猫的核心开发者之一Jeff Reback的话来说 ,“从语言的角度来看,直接检测链索引根本是不可能的。 必须进行推断”。

Consequently, the warning was introduced in version 0.13.0 near the end of 2013 as a solution to the silent failure of chained assignment encountered by many developers.

因此,该警告于2013年底左右在版本0.13.0中引入,以解决许多开发人员遇到的链式分配静默失败的问题。

Prior to version 0.12, the ix indexer was the most popular (in the pandas nomenclature, “indexers” such as ix, loc and iloc are simply constructs that allow objects to be indexed with square brackets just like arrays, but with special behavior). But it was around this time, in mid-2013, that the pandas project was beginning to gain momentum and catering to novice users was of rising importance. Since this release the loc and iloc indexers have consequently been preferred for their more explicit nature and easier to interpret usages.

在0.12版之前, ix索引器是最流行的(在熊猫命名法中,诸如ixlociloc类的“索引器”只是允许对象像数组一样使用方括号索引的结构,但具有特殊的行为)。 但是大约在这个时候, 即2013年中 ,熊猫项目开始获得发展势头,迎合新手用户的重要性日益提高。 从此版本开始,因此lociloc索引器因其更明确的性质和更易于解释的用法而受到青睐。

Google Trends: pandas

Google趋势:熊猫

The SettingWithCopyWarning has continued to evolve after its introduction, was hotly discussed in many GitHub issues for several years, and is even still being updated, but it’s here to stay and understanding it remains crucial to becoming a pandas expert.

SettingWithCopyWarning引入SettingWithCopyWarning一直在发展,在GitHub上的许多年中都进行了热烈的讨论 ,甚至还在进行更新 ,但是它仍然存在 ,并且了解它对于成为熊猫专家仍然至关重要。

结语 (Wrapping up)

翻译自: https://www.pybloggers.com/2017/07/understanding-settingwithcopywarning-in-pandas/

功夫熊猫中英文字幕版好句子

功夫熊猫中英文字幕版好句子_了解熊猫中的带有复制警告的设置相关推荐

  1. 功夫熊猫中英文字幕版好句子_熊猫生态系统中的4个必知图书馆

    功夫熊猫中英文字幕版好句子 Pandas is a very powerful and versatile Python data analysis library that expedites th ...

  2. java 复制 粘贴_在java中如何实现复制,粘贴,剪切

    在java中如何实现复制,粘贴,剪切 关注:272  答案:2  mip版 解决时间 2021-01-25 02:48 提问者挥映在沉默里的渲染 2021-01-24 22:41 请分别写出来,而且讲 ...

  3. python 创建目录时间_在目录中创建带有日期时间名称和子文件的dir(Python)

    我目前正在使用pythonv2.7在Linux上创建一个目录,目录名为日期和时间(即27-10-2011 23:00:01).我的密码是以下:在import time import os dirfmt ...

  4. python输出星期名缩写_在Python中解析带有时区缩写名称的日期/时间字符串?

    小编典典 dateutil的parser.parse()接受作为关键字参数tzinfos的类型的字典{'EST': -5*3600}(即,区域名称匹配GMT以秒偏移量).因此,假设我们有,我们可以这样 ...

  5. python多线程操作字典_在Python中使用带有线程的全局字典

    Dirk.. 52 假设CPython:是的,不是.从多个并发读/写请求不会破坏字典的意义上来说,从共享字典中获取/存储值实际上是安全的.这是由于实现维护的全局解释器锁("GIL" ...

  6. html画布360图案填充_在Photoshop中创建带有图案的抽象设计

    效果图 知识点: 应用选区工具结合图层混合模式和混合选项,创造出唯美的抽象类画册 效果 设计本身由一系列同心圆组成,每组的大小各不相同.每个圆都有6个核心色板的底色,然后渐变和图案填充会增加细节和深度 ...

  7. mysql 创建带参数的存储过程_在MySQL中创建带有IN和OUT参数的存储过程的方法

    在 MySQL 中创建储存过程的语法很难记,除非你经常跟储存过程打交道,原因很简单,语法不是什么小笑话.如果你通过命令行控制 MySQL,你需要记住准确的语法.一个快速示例可以很好的帮助你做到这点.在 ...

  8. java 实现复制_在java中如何实现复制,粘贴,剪切

    要用到java.awt.datatransfer包中的Clipboard类 import java.awt.*;import java.awt.event.*; import java.awt.dat ...

  9. java请求参数_在Java中发送http的post请求,设置请求参数等等

    前几天做了一个定时导入数据的接口,需要发送http请求,第一次做这种的需求,特地记一下子, 导包 import java.text.SimpleDateFormat; import java.util ...

最新文章

  1. Educational Codeforces Round 90 (Rated for Div. 2)部分题解
  2. go string 转 uint64_小改动,大提升:最近 Go 标准库的一次优化
  3. AI芯片下一步怎么走?“从软件中来,到软件中去”
  4. 功能、资源权限管理的设计
  5. 漫谈数据库索引 | 脚印 footprint(转载)
  6. spring step 1 : 什么是spring
  7. Redis PHP连接操作
  8. 前端wxml取后台js变量值_微信小程序云开发教程WXML入门数据绑定
  9. JeecgBoot版本4月份新版即将发布,抢先体验。。
  10. 带哨兵节点的链_BNC公链 | IPFS:区块链“不可能三角”的可能解
  11. CSocket,CAsyncSocket多线程退出时的一些注意事项(解决关闭WinSoket崩溃的问题)
  12. IIS6.0系统日志中出现此错误Timer_MinBytesPerSecond,Timer_ConnectionIdle
  13. 入侵排查篇---勒索病毒自救指南
  14. keras 基础入门整理
  15. FFmpeg 2 - ffplay、ffprobe、ffmpeg 命令使用
  16. BF算法与KMP算法
  17. 语言独立性和与语言无关的组件
  18. 大话设计模式之设计原则
  19. AUTOSAR MCAL详解: SPI (2)
  20. 【LeetCode】934. 最短的桥

热门文章

  1. html像素小鸟小游戏,微信小游戏-像素鸟游戏
  2. 学习笔记:Maxent的示例运行及部分结果解释
  3. zblog插件 php,ZBlogSEO插件
  4. 深度学习模型评价标准
  5. 笔记本电脑也是一种微型计算机,计算机一级试题 很权威的哦
  6. c语言的内存布局规律
  7. 汽车功能安全标准ISO 26262导入实践(下)
  8. 智和网管工业交换机网管方案
  9. GPS定位中的误差源及解决方法
  10. Word 注重页面细节才专业(添加页眉页脚,调整页边距,消灭孤行) | 职场人就应该这样用 Word