pc_represent_fund_merge_out=pc_represent_fund_merge_out.style.highlight_null(null_color='orange') 'Styler' object is not subscriptable
时间: 2024-03-15 08:46:43 浏览: 146
这个错误是因为你正在尝试对一个 `Styler` 对象进行索引,而 `Styler` 对象是不支持索引的。如果你想要对 `Styler` 对象进行索引,你需要先将其转换为 `DataFrame` 对象。例如:
```
pc_represent_fund_merge_out = pc_represent_fund_merge_out.style.highlight_null(null_color='orange').data
```
这样,你就可以对 `pc_represent_fund_merge_out` 进行索引了。
相关问题
pc_represent_celue_merge_out.reset_index(['org_id', 'org_full_name', 'fund_type_strategy_level1', 'fund_type_strategy_level2', '新逻辑策略所在产品数', '3.0策略所在产品数']) 'Requested level (org_id) does not match index name (None)'
这个问题通常出现在 Pandas 中,它表示你尝试使用 reset_index() 函数重置索引时,指定的列名与当前索引不匹配。可能是你在指定列名时写错了,或者是当前索引没有命名。你需要检查你的代码,确保指定的列名与当前索引匹配,或者在当前索引上先使用 reset_index() 函数将其命名。例如,可以使用 `df.reset_index().rename(columns={'index': 'new_index_name'})` 将当前索引命名为 "new_index_name"。然后再使用 `df.reset_index(['org_id', 'org_full_name', 'fund_type_strategy_level1', 'fund_type_strategy_level2', '新逻辑策略所在产品数', '3.0策略所在产品数'])` 重置索引。
下面 tensorflow代码转化为paddlepaddle2.2.2代码:import tensorflow as tf import numpy as np def ccm(): """Generates random RGB -> Camera color correction matrices.""" # Fixed XYZ -> Camera CCM. cam2xyz = [[0.4679,0.2145,0.3176],[0.1433,0.8236,0.0331],[0.0003,-0.3607,1.3604]] xyz2cam = tf.convert_to_tensor(np.linalg.inv(np.array(cam2xyz)),dtype = np.float32) # Multiplies with RGB -> XYZ to get RGB -> Camera CCM. rgb2xyz = tf.to_float([[0.4124564, 0.3575761, 0.1804375], [0.2126729, 0.7151522, 0.0721750], [0.0193339, 0.1191920, 0.9503041]]) rgb2cam = tf.matmul(xyz2cam, rgb2xyz) # Normalizes each row. rgb2cam = rgb2cam / tf.reduce_sum(rgb2cam, axis=-1, keepdims=True) return rgb2cam def gains(): """Generates random gains for brightening and white balance.""" # RGB gain represents brightening. rgb_gain = 1.0 # Red and blue gains represent white balance. red_gain = 1.0 / 0.5527 blue_gain = 1.0 / 0.4844 return rgb_gain, red_gain, blue_gain
这是一样的问题,上一个回答已经给出了代码转换的结果。以下是转换后的代码:
```python
import paddle.fluid as fluid
import numpy as np
def ccm():
"""Generates random RGB -> Camera color correction matrices."""
# Fixed XYZ -> Camera CCM.
cam2xyz = np.array([[0.4679,0.2145,0.3176],[0.1433,0.8236,0.0331],[0.0003,-0.3607,1.3604]], dtype=np.float32)
xyz2cam = fluid.layers.create_tensor(data=np.linalg.inv(cam2xyz), dtype='float32')
# Multiplies with RGB -> XYZ to get RGB -> Camera CCM.
rgb2xyz = np.array([[0.4124564, 0.3575761, 0.1804375],[0.2126729, 0.7151522, 0.0721750],[0.0193339, 0.1191920, 0.9503041]], dtype=np.float32)
rgb2cam = fluid.layers.matmul(xyz2cam, rgb2xyz)
# Normalizes each row.
rgb2cam = rgb2cam / fluid.layers.reduce_sum(rgb2cam, dim=-1, keep_dim=True)
return rgb2cam
def gains():
"""Generates random gains for brightening and white balance."""
# RGB gain represents brightening.
rgb_gain = 1.0
# Red and blue gains represent white balance.
red_gain = 1.0 / 0.5527
blue_gain = 1.0 / 0.4844
return rgb_gain, red_gain, blue_gain
```
阅读全文