首页 \ 问答 \ 从数据框创建数据框(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 ...

相关文章

更多

最新问答

更多
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • nginx 80端口反向代理多个域名,怎样隐藏端口的
  • xcode提醒样式,swift 3(xcode alert style, swift 3)
  • 在Chrome控制台中调试JavaScript(debugging javascript in Chrome console)
  • Javascript - 试图围绕自定义事件(Javascript - Trying to wrap my head around custom events)
  • 边栏链接不可点击(Sidebar links aren't clickable)
  • 使用recpatcha gem时如何显示其他表单错误?(How do I display other form errors when using the recpatcha gem?)
  • boost.python避免两次注册内部类,但仍然在python中公开(boost.python Avoid registering inner class twice but still expose in python)
  • Android 现在软件很少吗?以后会多起来吗
  • 如何在ActiveAdmin 0.5.0中为资源全局指定预先加载?(How to specify eager loading globally for a resource in ActiveAdmin 0.5.0?)
  • matlab代码为黄金比例持续分数(matlab code for golden ratio continued fraction)
  • Android浏览器触摸事件位置(Android browser touch event location)
  • 将cURL输出分配给Bash中的变量(Assign output to variable in Bash)
  • 我如何在MVC视图上没有时间获取当前日期(how i can get current date without time on MVC view)
  • sql连接函数(sql join of function)
  • 为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
  • 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])
  • 信阳方远计算机学校大专证被国家认可么
  • React / Rails AJAX POST请求返回404(React/Rails AJAX POST request returns 404)
  • Android与php服务器交互(Android interact with php server)
  • 自动刷新QTableWidget可能吗?(Refresh QTableWidget automatically possible?)
  • JVM / Compiler优化对象的未使用属性(optimization of unused properties of object by JVM / Compiler)
  • 插入表格时,乌克兰字符会更改为问号(Ukrainian character change to question mark when insert to table)
  • 在头文件中包含异常类(Including an exception class in a header file)
  • 完成c#中的执行后关闭sqlcmd(Close sqlcmd after finishing executing in c#)
  • 使用软导航栏正确检测屏幕尺寸(Detecting screensize correctly with soft navigation bar)
  • Typescript:从输入更新值(Typescript : update value from input)
  • 如何在执行某些行后仅在断点处停止?(How to only stop at a breakpoint after some line was executed?)
  • 以未定义的元素在JSON中循环(loop in JSON with undefined elements)