首页 \ 问答 \ 用多个头读取CSV(Read CSV with multiple Headers)

用多个头读取CSV(Read CSV with multiple Headers)

我有一个简单的CSV文件,我不知道如何拉入数据框。

test.csv

h1 h2 h3
11 12 13

h4 h5 h6
14 15 16

正如你所看到的,如果上面的csv被分成两个单独的文件,那么将它们读入一个数据框会很容易。 每组数据之间有一个空格,并且它们的长度始终相同。

数据框我想创建:

h1 h2 h3 h4 h5 h6
11 12 13 14 15 16


I have a simple CSV file that I can't figure out how to pull into a dataframe.

test.csv

h1 h2 h3
11 12 13

h4 h5 h6
14 15 16

As you can see if the csv above was split into two separate files then reading them into a dataframe would be easy. There is a space between each set of data and they are always the same length.

Dataframe I want to create:

h1 h2 h3 h4 h5 h6  
11 12 13 14 15 16  

原文:https://stackoverflow.com/questions/23165147
更新时间:2022-09-01 07:09

最满意答案

重点是它并不重要。 任何人都可以用一种稍微不同的方式来定义一个术语,并且通常各种作者都会根据他们使用这些术语的各种环境来调整意义。

试图找出哪一个是“正确的”,哪一个是“错误的”,你不会得到启发。 从上下文中引用的行情特别没有意义。

重要的是要理解底层的想法,而不用参考用来引用它们的词汇表。


The main point is that it doesn't really matter. Anyone can define a term in a slightly different way, and usually various authors adapt the meaning to the various contexts within which they use those terms.

You will not gain any enlightenment from trying to figure out which one is "right" and which one is "wrong". Quotes taken out of context are especially uninformative.

The important thing is to understand the underlying ideas without reference to the vocabulary items used to refer to them.

相关问答

更多
  • 数据隐藏是一种控制应用程序的一部分中的代码对应用程序的另一部分中的代码的 依赖性的方式。 也就是说,当一位代码发生变化时,一个或多个其他代码位是否也需要更新呢? 尽可能地,你希望答案是“不”,因为否则你对程序所做的每一点改变都会在程序进入稳定状态之前启动随之而来的大量变化,然后它将再次正常运行。 为了阻止程序员任意依赖于类的实现的任何方面,并鼓励他们只依赖于类的对象为客户端执行其预期功能所需的可控部分,您可以指定数据和/或允许客户端使用的功能:即“公共”和/或“受保护”接口。 您希望能够在没有客户端代码需要 ...
  • 封装是一种用作抽象的一部分的策略。 封装是指对象的状态 - 对象封装其状态并将其从外部隐藏; 类的外部用户通过其方法与它进行交互,但是不能直接访问类状态。 所以这个类抽象出与它的状态有关的实现细节。 抽象是一个更通用的术语,它也可以通过(其他)子类化来实现。 例如,标准库中的接口List是一系列项目的抽象,由它们的位置索引, List具体示例是ArrayList或LinkedList 。 与List进行交互的代码摘录了它正在使用的列表的详细信息。 抽象通常是不可能的,而不是通过封装来隐藏底层状态 - 如果一 ...
  • 这两个概念在某种程度上服务于同一目标,甚至Abstraction is more about the design, and encapsulation is more about the implementation (在讨论抽象时没有字段和数据)。 这个共同的目标是为用户提供一个简单且定义良好的界面,因此他不需要为细节而烦恼,而只需关心它的作用以及它如何与之连接。 例如,如果你看一下开/关开关,抽象将定义它的两个条件,以及它们之间切换的方式,封装将选择隐藏开关内的电线和东西,并让你看到熟悉的开关我们都知 ...
  • 封装既是数据绑定又是数据隐藏。 Java允许你公开数据,但如果你愿意,你应该有一个非常好的理由。 成员变量应作为默认私有变量,并且只有在绝对必要时才提升为更高的可见性。 Encapsulation is both data bundling and data hiding. Java allows you to expose data, but you should have a very good reason for it if you choose to do so. Member variables ...
  • 这取决于; 如果该值仅与方法有关,则将其作为该方法的返回值 如果该值与该对象相关,则通过属性将其公开 我怀疑它是后者,所以: public string Data { get { return data; } } 例如,它只是一个访问器 - 相当于java中的getData() 。 这不是暴露这个领域 ,但最终你的对象应该暴露一些 API的信息。 这并不意味着完全的秘密。 It depends; if the value relates only to the method, make it a ret ...
  • 重点是它并不重要。 任何人都可以用一种稍微不同的方式来定义一个术语,并且通常各种作者都会根据他们使用这些术语的各种环境来调整意义。 试图找出哪一个是“正确的”,哪一个是“错误的”,你不会得到启发。 从上下文中引用的行情特别没有意义。 重要的是要理解底层的想法,而不用参考用来引用它们的词汇表。 The main point is that it doesn't really matter. Anyone can define a term in a slightly different way, and us ...
  • 首先,不要过于雄心勃勃,正如你所说的这3个概念是相关的(特别是前两个),并且可以在许多情况下相互使用。 正确使用它们比完整的最终定义更重要。 “ 数据隐藏 ”就是在客户端和实现(部分)之间建立一个隔离墙。 模块的某些对象可以是模块的内部对象,对用户不可见。 因此,这是一种避免依赖的方法。 如果我不知道如何实现一件事,它的实现可能会改变。 “ 数据抽象 ”是在同一抽象下重新组合不同类型的数据。 它接近于协议的想法。 您不知道对象是如何实现的,但您知道它遵循一个众所周知的协议,即一组适用于不同类型数据的方法。 ...
  • 封装=信息隐藏=数据隐藏。 为了执行某项任务而不需要被他人知道的信息。 class Girl { private int age; Girl(int age) { this.age = age; } public boolean willGoOutWithGuy(boolean isGuyUgly) { return (age >= 22) && (!isGuyUgly); } } class Guy { private Girl girl = new Girl() ...
  • 你的问题非常有趣。 我会尽力向你回答。 封装背后的主要思想是隐藏其他用户的数据及其实现细节。 如果我们将数据成员设为私有 ,则只能在同一个类中访问它。 没有其他类可以直接访问该数据。 但我们可以定义一个接口,即公共getter和setter方法来更新其他类的数据。 这可确保其他人无法访问私有数据 ,并且只能通过您提供的公共方法访问。 例如,您可能决定仅为特定数据成员提供getter方法,而不提供setter方法。 这可确保任何其他类都无法以任何可能的方式更改或更新您的数据成员。 如果他们想要使用getter ...
  • 我猜这是因为人是可见的,所以它暴露了它的所有属性。 正确。 我是在正确的轨道上吗? 这是隐藏或公开您的属性/方法的正确方法吗? 如果你想这样做,那么是的,这是一种相当标准的方法。 从ES2015开始至少有另一种方式,但(可能)有更多的开销。 还有一个问题,为什么console.log(jack.getAge()); 抛出错误? 因为jack对象没有getAge属性,所以jack.getAge产生undefined ,这不是一个函数。 在giveAge闭包有权访问的上下文中有一个getAge 变量 (以及ag ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)