这是数据框:
State RegionName
0 NY New York
1 CA Los Angeles
2 IL Chicago 865
3 PA Philadelphia Wrin
4 AZ Phoenix City
我希望输出看起来像这样:
State RegionName
0 NY New
1 CA Los
2 IL Chicago
3 PA Philadelphia
4 AZ Phoenix
不使用for循环怎么做?
答案 0 :(得分:2)
通过索引将mouseY
用于选择第一个值:
edefine("custom/handlers/customChangeColorHandler",
[ "dojo/_base/declare",
"platform/ui/layout/_LayoutWidgetBase",
"dojo/_base/array",
"dojo/_base/lang",
"dojo/on",
"dojo/dom-construct",
"dojo/dom-attr",
"dojo/dom-class"],
function (declare, array, on, domConstruct, domAttr, domClass){
return ( ColorHandler){
changeWorkLogColor : function(eventContext){
var currentWO = CommonHandler._getAdditionalResource(eventContext,'workOrder').getCurrentRecord();
var worklogcount = currentWO.get("workloglistsize");
if (worklogcount){
eventContext.textWidget.domNode.className+= ' red-text';
}else{
eventContext.textWidget.domNode.className+= ' relatedRecords';
}
},
});
答案 1 :(得分:0)
df['RegionName'] = df['RegionName'].str.extract(r'(.*)\s')
但是我的第一个直觉是使用@jezrael提到的内容。
答案 2 :(得分:0)
您还可以<form name="reloadForm">
<button type="submit">
Continue
</button>
</form>
<script>
document.reloadForm.submit() ;
</script>
字符串的开头,但使用正则表达式排除空格str.extract
^[^\s]+
答案 3 :(得分:0)
您可以使用str.replace
用start_range = int(input("Enter the starting number: "))
end_range = int(input("Enter the ending number: "))
#find favourite numbers
def find_favourite_numbers(start_range,end_range):
fav_numbers = [70, 105, 140]
for start_range and end_range in range(fav_numbers):
if fav_numbers[0,1,2] >= start_range and fav_number <= end_range:
print(fav_numbers)
else:
print("favourite numbers not in range")
print(fav_numbers)
return fav_numbers
#Do not remove the next line
find_favourite_numbers(start_range,end_range)
替换多余的单词
''