在pandas DataFrame中,我需要过滤掉那些包含单词' fixed'的列。然后我想创建另一个只包含那些列的DataFrame。我怎么能这样做?
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@Entity
public class User {
public User() {
}
public User(String username, String password) {
super();
this.enabled=false;
}
@Id
@GeneratedValue
private Long id;
@NotNull
@Size(min=1, max=45)
private String username;
@NotNull
@Size(min=1, max=60)
private String password;
@NotNull
@Column(name = "enabled")
private boolean enabled;
@NotNull
@Size(min=1, max=45)
private String email;
private Integer condo_id;
@NotNull
private List<String> roles;
}
答案 0 :(得分:2)
只需使用.ix
属性:
fixed = [c for c in dataset.columns if c.startswith("fixed")]
fixed_dataset = dataset.ix[:, fixed]
同样的情况:
non_fixed = [c for c in dataset.columns if not c.startswith("fixed")]
dataset.ix[:, non_fixed]