首页 \ 问答 \ 从数据框创建数据框(Create a dataframe from a dataframe)

从数据框创建数据框(Create a dataframe from a dataframe)

我想从之前创建的数据框中创建一个数据框。 我的第一个数据框是:

    Sample motif chromosome
    1      CT-G.A    1
    1      TA-C.C    1
    1      TC-G.C    2
    2      CG-A.T    2
    2      CA-G.T    2

然后,我想创建一个如下所示的数据框(96 * 24-基序*染色体):

    Sample CT-G.A,chr1 TA-C.C,chr1 TC-G.C,chr1 CG-A.T,ch1 CA-G.T,ch1 CT-G.A,chr2 TA-C.C,chr2 TC-G.C,chr2 CG-A.T,ch2 CA-G.T,ch2 
    1       1             1           0           0            0        0          0     1    0     0      0      0
    2       0             0           0           0            0        0          0     0    0     0      1      1

I'd like to create a dataframe from a dataframe that created before. my first dataframe is:

    Sample motif chromosome
    1      CT-G.A    1
    1      TA-C.C    1
    1      TC-G.C    2
    2      CG-A.T    2
    2      CA-G.T    2

Then I want to create a dataframe like below, for all (96*24-motifs*chromosomes-):

    Sample CT-G.A,chr1 TA-C.C,chr1 TC-G.C,chr1 CG-A.T,ch1 CA-G.T,ch1 CT-G.A,chr2 TA-C.C,chr2 TC-G.C,chr2 CG-A.T,ch2 CA-G.T,ch2 
    1       1             1           0           0            0        0          0     1    0     0      0      0
    2       0             0           0           0            0        0          0     0    0     0      1      1

原文:https://stackoverflow.com/questions/48607092
更新时间:2024-04-23 11:04

最满意答案

如果您选择使用SINGLE_TABLE继承(这是代码中没有参数的@Inheritance注释的默认值),那么您应该将@DiscriminatorColumn注释添加到您的超类(和@DiscriminatorValue以扩展类)。 否则通过文档

如果未在实体层次结构的根目录中指定@DiscriminatorColumn且需要鉴别器列,则持久性提供程序假定默认列名为DTYPE,列类型为DiscriminatorType.STRING。

hibernate只是在你的表中找不到这个默认列。 您可以引入自己的descriminator列,或生成默认列


If you choose to use SINGLE_TABLE inheritance (which is default for @Inheritance annotation without arguments in your code) then you should add @DiscriminatorColumn annotation to your superclass (and @DiscriminatorValue to extending classes). Otherwise via documentation:

If @DiscriminatorColumn is not specified on the root of the entity hierarchy and a discriminator column is required, the Persistence provider assumes a default column name of DTYPE and column type of DiscriminatorType.STRING.

hibernate just can't find this default column in your table. You can introduce your own descriminator column, or generate default one

相关问答

更多
  • 扩展一个实体是一条路。 在Doctrine2世界中,他们讨论继承映射。 这里有一个代码示例。 它定义了一个BaseEntity然后将其扩展为创建一个BaseAuditableEntity ,最后还有一个扩展BaseAuditableEntity的User实体。 诀窍是使用@Orm\MappedSuperclass注解。 即使在我的关系图中有三个实体,此继承方案也会创建单个表。 这会将所有属性合并到一个表中。 创建的表格将包含通过关系映射的每个属性,即BaseAuditableEntity和User的属性。 ...
  • 唯一的方法是覆盖SaveChanges ,找到更改的实体并为它们调用您的例程。 public override int SaveChanges() { var entities = ChangeTracker.Entries() .Where(e => e.State == EntityState.Modified) .Select(e => e.Enti ...
  • 您可以尝试创建一个抽象基类UtenteBase: @MappedSuperClass public abstract class UtenteBase implements Serializable { //all mapped columns go here } 之前在Utente中的所有映射列现在都在此类中。 然后,您可以使用上面提到的两个类扩展此类: @Entity @Table(name = "utente") public class Utente extends UtenteBase { ...
  • 一些建议...... 您可以使用类别(Objective-C)或扩展(Swift)扩展实体类。 尽管苹果公司发出警告,但这通常是安全的。 至少,我已经使用了实体类的扩展而没有任何问题。 生成类后,可以很容易地为新实体字段手动添加属性。 您不需要重新生成类文件只是为了获得一点代码。 如果您使用的是源代码管理系统,则可以重新生成类,然后将重新生成的类与版本化的类合并。 这很容易让您保留自定义代码,同时获得生成代码的好处。 Some suggestions... You can extend the entity ...
  • 问题可能在于您的IsEntity约定。 目前,它将为Entity类本身返回true。 只需添加另一张支票: IsEntity((type, declared) => { return baseType.IsAssignableFrom(type) && !type.IsInterface && type != typeof(Entity); // <- skip Entity class }); 编辑 此外,您的CustomModelMapper类中有两个构造函数。 其中一个 ...
  • 不,实体不能扩展嵌入。 在JPA 2.0规范中,这被告知如下: 一个实体可以有一个非实体超类,它可以是具体的或抽象的类。[22] ... [22]超类不能是可嵌入的类或id类。 关系的目标也必须是实体。 可嵌入不是实体,它没有自己的身份。 如果要收集嵌入式,请使用@ElementCollection 。 No, entity cannot extend embeddable. In JPA 2.0 specification this is told as follows: An entity can ha ...
  • 如果仅在业务逻辑中使用它,而不是将其映射为数据库中的列。 您需要添加[NotMapped]属性。 [NotMapped] public string CustomerName { get; set; } If you use it only in the business logic and not intended to map it as a column in the database. You need to add [NotMapped] attribute. [NotMapped] publi ...
  • 如果您选择使用SINGLE_TABLE继承(这是代码中没有参数的@Inheritance注释的默认值),那么您应该将@DiscriminatorColumn注释添加到您的超类(和@DiscriminatorValue以扩展类)。 否则通过文档 : 如果未在实体层次结构的根目录中指定@DiscriminatorColumn且需要鉴别器列,则持久性提供程序假定默认列名为DTYPE,列类型为DiscriminatorType.STRING。 hibernate只是在你的表中找不到这个默认列。 您可以引入自己的de ...
  • 发现错误。 生成的Pick.h具有以下内容: @class Picker @interface Pick : NSManagedObject @property (nonatomic, retain) NSManagedObject *game; @property (nonatomic, retain) Picker *picker; 将其更改为: @interface Pick : NSManagedObject @property (nonatomic, retain) NSManagedObj ...
  • 正如你在宣言中看到的那样 public partial class WebApplication1Entities : DbContext 这个班是partial 。 因此,您可以创建另一个* .cs文件并将代码放在那里(使用相同的命名空间!): public partial class WebApplication1Entities { public WebApplication1Entities(string connectionString) : base(connectionString ...

相关文章

更多

最新问答

更多
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 高考完可以去做些什么?注意什么?
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • Flask中的自定义中止映射/异常(Custom abort mapping/exceptions in Flask)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 怎么在《我的世界》游戏里面编程
  • .NET可移植可执行文件VS .NET程序集(.NET Portable Executable File VS .NET Assembly)
  • 搜索字符串从视图中键入两个字段的“名字”和“姓氏”组合(Search Strings Typed from View for Two Fields 'First Name' and 'Last Name' Combined)
  • 我可以通过配置切换.Net缓存提供程序(Can I switch out .Net cache provider through configuration)
  • 在鼠标悬停或调整浏览器大小之前,内容不会加载(Content Does Not Load Until Mouse Hover or Resizing Browser)
  • 未捕获的TypeError:auth.get不是函数(Uncaught TypeError: auth.get is not a function)
  • 如何使用变量值创建参数类(How to create a parameter class with variant value)
  • 在std :: deque上并行化std :: replace(Parallelizing std::replace on std::deque)
  • 单元测试返回Connection对象的方法(Unit Test for a method that returns a Connection object)
  • rails:上传图片时ios中的服务器内部错误(rails: server internal error in ios while uploading image)
  • 如何在Android中构建应用程序警报[关闭](How build an application Alarm in Android [closed])
  • 以编程方式连接到Windows Mobile上的蓝牙耳机(Programmatically connect to bluetooth headsets on Windows Mobile)
  • 在两个不同的SharedPreference中编写并获得相同的结果(Writing in two different SharedPreference and getting the same result)
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • 在'x','y','z'迭代上追加数组(Append array on 'x', 'y', 'z' iteration)
  • 我在哪里可以看到使用c ++源代码的UML方案示例[关闭](Where I can see examples of UML schemes with c++ source [closed])
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • 位字段并集的大小,其成员数多于其大小(Size of bit-field union which has more members than its size)
  • 我安装了熊猫,但它不起作用(I installed pandas but it is not working)
  • Composer - 更改它在env中使用的PHP版本(Composer - Changing the version of PHP it uses in the env)
  • 使用JavaFX和Event获取鼠标位置(Getting a mouse position with JavaFX and Event)
  • 函数调用可以重新排序(Can function calls be reordered)
  • 关于“一对多”关系的NoSQL数据建模(NoSQL Data Modeling about “one to many” relationships)
  • 如何解释SBT错误消息(How to interpret SBT error messages)
  • 调试模式下的Sqlite编译器错误“初始化程序不是常量”(Sqlite compiler errors in Debug mode “initializer is not a constant”)