从数据框创建数据框(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

相关问答

更多

你如何像在Symfony 1中一样在Symfony 2中扩展一个实体?(How do you extend an entity in Symfony2 like you used to be able to in Symfony 1?)

扩展一个实体是一条路。 在Doctrine2世界中,他们讨论继承映射。 这里有一个代码示例。 它定义了一个BaseEntity然后将其扩展为创建一个BaseAuditableEntity ,最后还有一个扩展BaseAuditableEntity的User实体。 诀窍是使用@Orm\MappedSuperclass注解。 即使在我的关系图中有三个实体,此继承方案也会创建单个表。 这会将所有属性合并到一个表中。 创建的表格将包含通过关系映射的每个属性,即BaseAuditableEntity和User...

将实体框架保存在单个实体类型上(Extend Entity Framework Save on a single Entity Type)

唯一的方法是覆盖SaveChanges ,找到更改的实体并为它们调用您的例程。 public override int SaveChanges() { var entities = ChangeTracker.Entries<Entity1>() .Where(e => e.State == EntityState.Modified) .Select(e => e...

当子类只有@Transient字段时扩展@Entity的最佳方法(The best way to extend an @Entity when the subclass has just a @Transient field besides)

您可以尝试创建一个抽象基类UtenteBase: @MappedSuperClass public abstract class UtenteBase implements Serializable { //all mapped columns go here } 之前在Utente中的所有映射列现在都在此类中。 然后,您可以使用上面提到的两个类扩展此类: @Entity @Table(name = "utente") public class Utente extends UtenteB...

如何扩展核心数据实体类(How to extend core data entity classes)

一些建议...... 您可以使用类别(Objective-C)或扩展(Swift)扩展实体类。 尽管苹果公司发出警告,但这通常是安全的。 至少,我已经使用了实体类的扩展而没有任何问题。 生成类后,可以很容易地为新实体字段手动添加属性。 您不需要重新生成类文件只是为了获得一点代码。 如果您使用的是源代码管理系统,则可以重新生成类,然后将重新生成的类与版本化的类合并。 这很容易让您保留自定义代码,同时获得生成代码的好处。 Some suggestions... You can extend the e...

无法扩展未映射的类:实体(Cannot extend unmapped class: Entity)

问题可能在于您的IsEntity约定。 目前,它将为Entity类本身返回true。 只需添加另一张支票: IsEntity((type, declared) => { return baseType.IsAssignableFrom(type) && !type.IsInterface && type != typeof(Entity); // <- skip Entity class }); 编辑 此外,您的CustomModelMapper类中有两个构造函数。...

我们可以从@Embedded类扩展@Entity类(Can we extends @Entity class from @Embedded class)

不,实体不能扩展嵌入。 在JPA 2.0规范中,这被告知如下: 一个实体可以有一个非实体超类,它可以是具体的或抽象的类。[22] ... [22]超类不能是可嵌入的类或id类。 关系的目标也必须是实体。 可嵌入不是实体,它没有自己的身份。 如果要收集嵌入式,请使用@ElementCollection 。 No, entity cannot extend embeddable. In JPA 2.0 specification this is told as follows: An entity c...

如何扩展Entity Framework 6模型(How to extend an Entity Framework 6 model)

如果仅在业务逻辑中使用它,而不是将其映射为数据库中的列。 您需要添加[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] ...

如何扩展@Entity(How to extend an @Entity)

如果您选择使用SINGLE_TABLE继承(这是代码中没有参数的@Inheritance注释的默认值),那么您应该将@DiscriminatorColumn注释添加到您的超类(和@DiscriminatorValue以扩展类)。 否则通过文档 : 如果未在实体层次结构的根目录中指定@DiscriminatorColumn且需要鉴别器列,则持久性提供程序假定默认列名为DTYPE,列类型为DiscriminatorType.STRING。 hibernate只是在你的表中找不到这个默认列。 您可以引入...

插入扩展抽象实体的实体时出错(Error when inserting entities which extend an Abstract Entity)

发现错误。 生成的Pick.h具有以下内容: @class Picker @interface Pick : NSManagedObject @property (nonatomic, retain) NSManagedObject *game; @property (nonatomic, retain) Picker *picker; 将其更改为: @interface Pick : NSManagedObject @property (nonatomic, retain) NSManag...

如何扩展Entity Framework 6.1.3生成的类?(How to extend an Entity Framework 6.1.3 generated class?)

正如你在宣言中看到的那样 public partial class WebApplication1Entities : DbContext 这个班是partial 。 因此,您可以创建另一个* .cs文件并将代码放在那里(使用相同的命名空间!): public partial class WebApplication1Entities { public WebApplication1Entities(string connectionString) : base(connectionS...

相关文章

更多

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

She’s Not Carrying A Handbag

Gao Yuanyuan from after 2005 drama &quot; world fir ...

ServletOutputStream cannot be resolved to a type

在使用jsp生成web图片时遇到这个问题,这是源代码中的一条语句,源代码可以执行,可是一将源码放入ec ...

Create a Bootable MicroSD Card

http://gumstix.org/create-a-bootable-microsd-card.h ...

Book Report: THE SOUL OF A NEW MACHINE

Book Report: THE SOUL OF A NEW MACHINE Zhengdong Zh ...

Solr: a custom Search RequestHandler

As you know, I've been playing with Solr lately, tr ...

A Great List of Windows Tools

Windowsis an extremely effective and a an efficient ...

How to Start a Business in 10 Days

With an executive staffing venture about to open, a ...

Spring Data: a new perspective of data operations

Spring Data: a new perspective of data operations ...

Drupal Forums instead of phpBB or vBulletin: A casestudy

5th Jan, 10 Drupal drupal advanced forum drupa ...

最新问答

更多

sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)

否(它不会使它们无法访问),是(您可以在没有停机的情况下运行它)。 sp_updatestats可以在没有停机的情况下针对实时数据库运行。 No (it doesn't make them inaccessible), and Yes (you can run it without downtime). sp_updatestats can be run against a live database without downtime.

如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)

最终,我们选择了使用Spark Framework for Java实现的后端REST API。 这可能不是最强大的,用户反馈一直是个问题。 我们将命令行界面拆分为提交REST调用,并将结果显示给用户。 Ultimately, we chose to go the route of having a backend REST API that was implemented with the Spark Framework for Java. This may not be the most r

AESGCM解密失败的MAC(AESGCM decryption failing with MAC)

您不能将Encoding.UTF8.GetString应用于任意二进制数据。 它只能解码使用UTF-8编码字符串的结果的字节。 .net实现将默默地破坏数据,而不是默认情况下抛出异常。 您应该使用Base64: Convert.FromBase64String和Convert.ToBase64String You can't apply Encoding.UTF8.GetString to arbitrary binary data. It can only decode bytes that

Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)

我希望能看到更多你的Sass代码等,但我的猜测是你需要在所有嵌套行上使用nest行为。 在我看来,基金会在Sass中的行主要是为了在一个层面上使用。 嵌套在另一行中的任何行都应使用nest行为,除非您希望在列上添加额外的填充。 在你的CodePen中,我能够通过向所有行添加一类collapse来修复列上填充的问题,我认为这与执行$behavior: nest相同$behavior: nest在Sass中$behavior: nest :

湖北京山哪里有修平板计算机的

京山有个联想的专卖店,那里卖平板电脑,地址在中百前面的十字路口右拐 ,他们应该会提供相关的维修服务。

SimplePie问题(SimplePie Problem)

我怀疑由于内容的性质(包含代码),stackoverflow提要不起作用。 我使用许多feed解析器看似“正常”的feed有类似的问题,尽管我最近运气最多的是Zend_Feed。 试试吧 I suspect the stackoverflow feed is not working due to the nature of the content (contains code). I have had similar issues with seemingly "normal" feeds us

在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)

是的,您可以通过getApplicationContext()任意数量的时间(后台任务), getApplicationContext()仅返回应用程序的context 。 Yes, you can pass getApplicationContext() any number of time (Background Tasks ) you want, getApplicationContext() simply returns context of the application.

HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)

这是我最终做的事情: 我无法以这种方式提供完全访问权限,而是在project level folder中设置了一个虚拟HTML页面,该页面单击自身以重定向到位于separate, non-project util folder的HTML文件。 这允许我保留除了那个之外的所有内容,非常小的文件分开但不存在文件访问问题。 Here is what I ended up doing: I wasn't able to provide full access exactly this way, but

为什么我会收到链接错误?(Why do I get a linker error?)

看起来您的编译器错误地将名称引入到全局名称空间中,而不是C ++ 11 3.5 / 7中指定的最内层名称空间( Bushman ): 如果没有找到具有链接的实体的块范围声明来引用某个其他声明,那么该实体是最内层封闭名称空间的成员。 代码按照预期在GCC上编译: http : //ideone.com/PR4KVC 你应该能够通过在构造函数的块作用域中声明它之前(或代替它)在正确的名称空间中声明该函数来解决该bug。 但是,我无法访问您的编译器来测试它。 It looks like your co

如何正确定义析构函数(How to properly define destructor)

在C ++中,你需要手动释放内存。 没有垃圾收集器。 您显然需要在析构函数内手动释放内存。 如果您使用new分配内存,则需要对在deconstructor中使用new分配的每个资源使用delete ,例如: class1::~class1(void) { delete resource1; delete resource2; etc... } In C++ you need to free the memory manually. There's no garbage