在vim中定义颜色变量(Defining a color variable in vim)

例如,当制作colorscheme时,如何将#40ffff定义为“UglyColor”(即作为变量)?

可能/不可能吗?


When, for example, making a colorscheme, how can one define #40ffff as "UglyColor" (i.e. as a variable) ?

Possible / not possible ?


原文:https://stackoverflow.com/questions/2444072
2024-04-23 12:04

满意答案

使用pandas,避免将NaN与整数相结合

除非你有充分的理由,否则请避免这种做法。 原因是pandas只允许在连续内存块中使用向量化计算。 这仅适用于相同类型的数据,例如一系列类型为intfloatdatetime ,但不是 object

NaN被认为是float 。 因此,将整数与NaN组合会强制将pandas强制转换为float整个系列。 这会增加内存使用量,但对于大多数使用情况不是问题。

如果你NaN和整数结合起来,你需要用dtype=object创建一个系列,并且让pandas使用一系列指针。 这是昂贵的计算和内存密集型。 除非你绝对必须,否则不要这样做。

但如果你只是......

在将非NaN元素转换为整数之前,您可以将一个序列转换为object

df['B'] = df['B'].astype(object)

如上所述,您要求pandas / numpy使用系列中每个项目的指针。 您也可以开始使用列表。


With pandas, avoid combining NaN with integers

Unless you have an extremely good reason, avoid this practice. The reason is pandas only allows vectorised computations with arrays in contiguous memory blocks. This is only possible with data of the same type, e.g. a series of type int, float, datetime, but not object.

NaN is considered float. Therefore, combining integers with NaN forces pandas to, by default, upcast the entire series to float. This increases memory usage, but for most use cases is not an issue.

If you wish to combine NaN with integers, you need to create a series with dtype=object, and have pandas work with a series of pointers. This is expensive computationally and memory-intensive. Do not do it unless you absolutely must.

But if you simply must...

You can convert a series to object before converting non-NaN elements to integers:

df['B'] = df['B'].astype(object)

As explained above, you are asking pandas / numpy to work with a pointer for each item in your series. You might as well start working with lists instead.

相关问答

更多

将多个过滤器应用于大熊猫DataFrame或Series的高效方法(Efficient way to apply multiple filters to pandas DataFrame or Series)

熊猫(和numpy)允许布尔索引 ,这将更有效: In [11]: df.loc[df['col1'] >= 1, 'col1'] Out[11]: 1 1 2 2 Name: col1 In [12]: df[df['col1'] >= 1] Out[12]: col1 col2 1 1 11 2 2 12 In [13]: df[(df['col1'] >= 1) & (df['col1'] <=1 )] Out[13]: col...

使用浮动切片列表切片大熊猫系列(Slicing a pandas series using a list of float slices)

它需要一些聪明的numpy array广播来检查index每个值,如果值在interval列表中的每个区间之间(两端都打开,那么> = low_end和<= high_end): In [158]: import numpy as np def f(a1, a2): return (((a1 - a2[:,:,np.newaxis])).prod(1)<=0).any(0) In [159]: f(s.index.values, np.array(intervals)) Out[159]...

大熊猫系列累积argmax(pandas series cumulative argmax)

你不需要cumargmax功能。 相反,你可以在一行中做到这一点, pd.expanding_apply(series, lambda x: x.argmax()) pandas 0.18正在弃用expanding_apply()模块级功能。 他们正在用以下方法调用替换, series.expanding().apply(lambda x: x.argmax()) 查看http://pandas.pydata.org/pandas-docs/stable/computation.html上的文...

访问大熊猫系列timedeltas的`.days`(Accessing `.days` for a pandas Series of timedeltas)

使用.dt访问器: print(pd.Series(tds).dt.days) 输出: 0 30 1 29 2 28 3 27 4 26 5 25 6 24 7 23 8 22 9 21 dtype: int64 Use .dt accessor: print(pd.Series(tds).dt.days) Output: 0 30 1 29 2 28 3 27 4 26 5 25 6 24...

pd.notnull的奇怪的空检查行为(Weird null checking behaviour by pd.notnull)

以下是与此行为相关的问题: https : //github.com/pandas-dev/pandas/issues/20675 。 简而言之,如果传递给notnull参数是类型list ,则在内部使用np.asarray方法将其转换为np.array 。 发生此错误,因为,如果没有指定np.nan ,numpy会将np.nan转换为string ( np.nan无法将其识别为空值): a = ['A4', np.nan] np.asarray(a) # array(['A4', 'nan'],...

Pandas notnull不在数据框中的列上工作(Pandas notnull is not working on column in data frame)

此列永远不会为null。 如果行中的每个项目都不是基本字符串,则函数返回'' 。 因此以下应该有效: df_merged = df_merged[df_merged['Combined_ID'] != ''] This column is never going to be null. If every item in the row is not a basestring then the function returns ''. Therefore the following should ...

大熊猫系列的功能组成(functional composition of pandas' Series)

这就是map的用途。 只做u = s.map(t) 。 That's what map is for. Just do u = s.map(t).

大熊猫指定一个用notnull()过滤的系列,(Pandas Assigning back a series that was filtered with notnull())

使用pandas,避免将NaN与整数相结合 除非你有充分的理由,否则请避免这种做法。 原因是pandas只允许在连续内存块中使用向量化计算。 这仅适用于相同类型的数据,例如一系列类型为int , float , datetime ,但不是 object 。 NaN被认为是float 。 因此,将整数与NaN组合会强制将pandas强制转换为float整个系列。 这会增加内存使用量,但对于大多数使用情况不是问题。 如果你NaN和整数结合起来,你需要用dtype=object创建一个系列,并且让pan...

我们应该总是使用@NotNull还是@Nullable?(Should we always use @NotNull or @Nullable?)

在Java中,原始类型(如int永远不能为null ,这由编译器强制执行,因此代码中的注释是完全不必要的。 即使您设法将Integer作为参数传递(通过自动拆箱),但在大多数情况下将不允许使用null值: add(1, (Integer) null); => Null pointer access: This expression of type Integer is null but requires auto-unboxing. 但是,如果null设置为参数传递(例如,如果其中一个参数为nu...

为什么我不能将事件标记为NotNull?(Why can't I mark an event as NotNull?)

如果您想这样做,您可以更改属性(添加标志AttributeTargets.Event )以添加对版本8中的事件的支持。 namespace JetBrains.Annotations { /// <summary> /// Indicates that the value of the marked element could never be <c>null</c> /// </summary> /// <example><code> /// [NotNu...

相关文章

更多

secureCRT使用VIM 像LINUX中那样对语法高亮

1.在SecureCRT中 secureCRT使用VIM时对语法高亮 其实不是secureCRT的功能 ...

WebStorm安装Vim以及快捷键设置

运气好,赶上了2012年12月21日“世界末日”的促销活动,便宜买到了这款号称The smartest ...

ServletOutputStream cannot be resolved to a type

在使用jsp生成web图片时遇到这个问题,这是源代码中的一条语句,源代码可以执行,可是一将源码放入ec ...

How to Start a Business in 10 Days

With an executive staffing venture about to open, a ...

HTML 超链接(a标签、锚)

a标签: anchor锚 1.超链接 -&gt; 点击之后跳转页面 格式: 协 ...

Become a Master Designer: Rule Three: Contrast, Contrast, Contrast

Part Three of Seven Easy Principles to Becoming a M ...

Securing Solr on Tomcat access using a user account

Open [Tomcat install dir]\tomcat-users.xmlfor editi ...

trouble is a friend

trouble will find you no matter where you go, oh ...

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

最新问答

更多

sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)

否(它不会使它们无法访问),是(您可以在没有停机的情况下运行它)。 sp_updatestats可以在没有停机的情况下针对实时数据库运行。 No (it doesn't make them inaccessible), and Yes (you can run it without downtime). sp_updatestats can be run against a live database without downtime.

如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)

最终,我们选择了使用Spark Framework for Java实现的后端REST API。 这可能不是最强大的,用户反馈一直是个问题。 我们将命令行界面拆分为提交REST调用,并将结果显示给用户。 Ultimately, we chose to go the route of having a backend REST API that was implemented with the Spark Framework for Java. This may not be the most r

AESGCM解密失败的MAC(AESGCM decryption failing with MAC)

您不能将Encoding.UTF8.GetString应用于任意二进制数据。 它只能解码使用UTF-8编码字符串的结果的字节。 .net实现将默默地破坏数据,而不是默认情况下抛出异常。 您应该使用Base64: Convert.FromBase64String和Convert.ToBase64String You can't apply Encoding.UTF8.GetString to arbitrary binary data. It can only decode bytes that

Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)

我希望能看到更多你的Sass代码等,但我的猜测是你需要在所有嵌套行上使用nest行为。 在我看来,基金会在Sass中的行主要是为了在一个层面上使用。 嵌套在另一行中的任何行都应使用nest行为,除非您希望在列上添加额外的填充。 在你的CodePen中,我能够通过向所有行添加一类collapse来修复列上填充的问题,我认为这与执行$behavior: nest相同$behavior: nest在Sass中$behavior: nest :

湖北京山哪里有修平板计算机的

京山有个联想的专卖店,那里卖平板电脑,地址在中百前面的十字路口右拐 ,他们应该会提供相关的维修服务。

SimplePie问题(SimplePie Problem)

我怀疑由于内容的性质(包含代码),stackoverflow提要不起作用。 我使用许多feed解析器看似“正常”的feed有类似的问题,尽管我最近运气最多的是Zend_Feed。 试试吧 I suspect the stackoverflow feed is not working due to the nature of the content (contains code). I have had similar issues with seemingly "normal" feeds us

在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)

是的,您可以通过getApplicationContext()任意数量的时间(后台任务), getApplicationContext()仅返回应用程序的context 。 Yes, you can pass getApplicationContext() any number of time (Background Tasks ) you want, getApplicationContext() simply returns context of the application.

HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)

这是我最终做的事情: 我无法以这种方式提供完全访问权限,而是在project level folder中设置了一个虚拟HTML页面,该页面单击自身以重定向到位于separate, non-project util folder的HTML文件。 这允许我保留除了那个之外的所有内容,非常小的文件分开但不存在文件访问问题。 Here is what I ended up doing: I wasn't able to provide full access exactly this way, but

为什么我会收到链接错误?(Why do I get a linker error?)

看起来您的编译器错误地将名称引入到全局名称空间中,而不是C ++ 11 3.5 / 7中指定的最内层名称空间( Bushman ): 如果没有找到具有链接的实体的块范围声明来引用某个其他声明,那么该实体是最内层封闭名称空间的成员。 代码按照预期在GCC上编译: http : //ideone.com/PR4KVC 你应该能够通过在构造函数的块作用域中声明它之前(或代替它)在正确的名称空间中声明该函数来解决该bug。 但是,我无法访问您的编译器来测试它。 It looks like your co

如何正确定义析构函数(How to properly define destructor)

在C ++中,你需要手动释放内存。 没有垃圾收集器。 您显然需要在析构函数内手动释放内存。 如果您使用new分配内存,则需要对在deconstructor中使用new分配的每个资源使用delete ,例如: class1::~class1(void) { delete resource1; delete resource2; etc... } In C++ you need to free the memory manually. There's no garbage