首页 \ 问答 \ Python转置,列名在数据帧记录内(Python transpose, column name are inside the dataframe records)

Python转置,列名在数据帧记录内(Python transpose, column name are inside the dataframe records)

我很确定我在这里遗漏了一些非常基本的东西,但我并没有真正找到我在pandas文档中寻找的内容。

我下载了一个ForEx数据框,并希望保存它,但在我这样做之前,我必须将其格式化为8列/ X行,矩阵/数据帧/向量(根据需要多行)。 我把它作为一行,每个记录旁边都有他的列名。 (我可以将它保存在.CSV中)

我在这里的权力是.transpose,仅此而已。

我已经成功了这一次,但我似乎已经忘记了保存代码而且它已经有一段时间了......但是多亏了这个我可以告诉你一个较旧的csv我读到python,并显示我想要的格式化它。

(列名:索引(不是真正的列,它只是索引),关闭,日期,高,低,打开,关闭,qouteVolume,音量,weightedAvarage)

在此处输入图像描述 在此处输入图像描述

    source_df = get_ForEx_data(**params)
list(source_df )
list(TransposedData)
TransposedData = source_df .transpose()

编辑:(从互联网获取数据的功能)

def get_poloinex_data(s, a, b, c):

import requests
from pandas import DataFrame
from io import StringIO

url = 'https://poloniex.com/public?command=returnChartData'

url += '&currencyPair=' + s #USDT a dollár
url += '&start=' + a
url += '&end=' + b
url += '&period=' + c

csv = requests.get(url)

if csv.ok:
    return DataFrame.from_csv(StringIO(csv.text), sep=',') #Separátor itt!
else:
    return None

我在python中使用的数据是这样的:

Columns: [high:1.85, low:0.50000021, open:1.65, close:1.85, volume:144.42819254, quoteVolume:84.01638508, weightedAverage:1.71904792}, {"date":1439020800, high:1.7, low:1.40000001, open:1.7, close:1.40000001, volume:129.57577588, quoteVolume:92.52305316, weightedAverage:1.40047016}, {"date":1439035200, high:1.40000001, low:1.40000001.1, open:1.40000001, close:1.40000001.1, volume:0, quoteVolume:0, weightedAverage:1.40000001}, {"date":1439049600, high:1.40000001.1, low:1.40000001.2, open:1.40000001.1, close:1.40000001.2, volume:0.1, quoteVolume:0.1, weightedAverage:1.40000001}.1, {"date":....

我要找的是这样的:

              close                 date       high        low       open  \
0      1.850000  2015-08-08 04:00:00   1.850000   0.500000   1.650000   
1      1.400000  2015-08-08 08:00:00   1.700000   1.400000   1.700000   
2      1.400000  2015-08-08 12:00:00   1.400000   1.400000   1.400000   
3      1.400000  2015-08-08 16:00:00   1.400000   1.400000   1.400000

等等剩下的列


I'm quite sure that I'm missing something very elementary here, but I didn't really found what i was looking for in the pandas documentation.

I download a ForEx data-frame , and want to save it, but before I do that, I have to format it to a 8 columns/X rows, matrix/data-frame/vector (as many rows as needed). I have it as a line with every record having his column name next to it. (I can save it in .CSV)

My powers here are .transpose, which alone isn't doing the trick.

I already succeded with this once, but I seems to have forgotten to save the code and it was a while back.... But thanks to this I can show you an older csv I read in to python, and show how I want to format it.

(column names: Index(not really a column, it is just the index),close,date,high,low,open,close,qouteVolume,volume,weightedAvarage)

enter image description here enter image description here

    source_df = get_ForEx_data(**params)
list(source_df )
list(TransposedData)
TransposedData = source_df .transpose()

Edit: (function that gets the data from the internet)

def get_poloinex_data(s, a, b, c):

import requests
from pandas import DataFrame
from io import StringIO

url = 'https://poloniex.com/public?command=returnChartData'

url += '&currencyPair=' + s #USDT a dollár
url += '&start=' + a
url += '&end=' + b
url += '&period=' + c

csv = requests.get(url)

if csv.ok:
    return DataFrame.from_csv(StringIO(csv.text), sep=',') #Separátor itt!
else:
    return None

The data I get using this is like this in python:

Columns: [high:1.85, low:0.50000021, open:1.65, close:1.85, volume:144.42819254, quoteVolume:84.01638508, weightedAverage:1.71904792}, {"date":1439020800, high:1.7, low:1.40000001, open:1.7, close:1.40000001, volume:129.57577588, quoteVolume:92.52305316, weightedAverage:1.40047016}, {"date":1439035200, high:1.40000001, low:1.40000001.1, open:1.40000001, close:1.40000001.1, volume:0, quoteVolume:0, weightedAverage:1.40000001}, {"date":1439049600, high:1.40000001.1, low:1.40000001.2, open:1.40000001.1, close:1.40000001.2, volume:0.1, quoteVolume:0.1, weightedAverage:1.40000001}.1, {"date":....

what I looking for is like this:

              close                 date       high        low       open  \
0      1.850000  2015-08-08 04:00:00   1.850000   0.500000   1.650000   
1      1.400000  2015-08-08 08:00:00   1.700000   1.400000   1.700000   
2      1.400000  2015-08-08 12:00:00   1.400000   1.400000   1.400000   
3      1.400000  2015-08-08 16:00:00   1.400000   1.400000   1.400000

and so on with the remaining columns


原文:https://stackoverflow.com/questions/43479858
更新时间:2023-09-20 14:09

最满意答案

它似乎可行。 关于针对ARM的交叉编译tesseract-ocr的这个错误报告以一种解决方法结束,声称它可以从那里开始工作: http//code.google.com/p/tesseract-ocr/issues/detail?id = 262


It does seem doable. This bug report on cross compiling tesseract-ocr for ARM ends with a workaround and the claim that it works from there on: http://code.google.com/p/tesseract-ocr/issues/detail?id=262

相关问答

更多
  • 一、需要的软件 1、pytesseract 2、PIL或者是pillow都可以 3、tesseract-ocr 第一、二两个都可以通过pip安装,第三个百度就可以找到。 二、使用方法 1.先用PIL打开图片 2.调用pytesseract的image_to_string()方法即可,简单吧!
  • 我发现了如何将图像上的区域传递给Tesseract。 虽然无法通过命令行完成,但Tesseract 3.02 API支持函数SetRectangle(int left, int top, int width, int height) ,允许您将文本提取限制为指定的区域。 它必须在SetImage()函数之后SetImage() 。 再次感谢。 I found out how to pass in regions on an image to Tesseract. Although it cannot be ...
  • opencv专注机器视觉 tesseract专注字符识别 opencv貌似研究的更广
  • 我使用了这些说明,并在Centos中正常工作 在Centos中从源代码安装Tesseract OCR库 下载Leptonica和Teseract资料来源: $ wget http://www.leptonica.org/source/leptonica-1.69.tar.gz $ wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz 配置,编译,安装库: $ tar xzvf leptonica-1.69.t ...
  • 300dpi是我在各种Tesseract文档( FAQ )中经常看到的值。 高于此可能会或可能不会产生更好的结果,但由于图像较大,它肯定会增加处理时间。 300dpi is the value I frequently see in various Tesseract documentations (FAQ). Higher than that may or may not produce better results but it definitely increases the processing t ...
  • 以下是在图像上使用tesseract后得到的结果 !HerTürdenErutikyıdeplç'nTıklaSımsıkainlemereoyoAnındaCebirıdenIdeIziemeklçin18YaşındanBüyükoin'akZorunludur.HerkamgoridenyüzleroevideoHighDefTvde高DefTv,abonelik“servistir.Pakelhaîlaliktümvergilerdahilolamkayda64TLyebtaIedimedig'sü ...
  • 好的,所以我的问题是在我的项目中添加和删除对库的引用几次后,我的库搜索路径中出现了很多问题。 另外,我没有将新的“include”文件夹(在构建tesseract时创建)添加到用户标题搜索路径。 因此,只需快速回顾一下,为了使用libc ++构建tesseract-ocr,它可以与更新的OpenCV版本一起使用: 下载leptonica-1.69 下载tesseract 3.02 将它们安排在原始教程中解释的文件夹结构中 将此脚本下载到同一文件夹。 编辑相关IOS_BASE_SDK和IOS_DEPLOY_T ...
  • 考虑使用pytesseract,在python 3.6上为我工作:pip install pytesseract 如果您在运行上述命令时遇到直接安装问题,请尝试以下链接: http : //www.lfd.uci.edu/~gohlke/pythonlibs/ 使用“查找”工具查找pytesseract,并在其下载的目录中,按住shift并右键单击,您将获得一个选项,在那里打开命令窗口并运行: 点击安装“文件名” 您也可以尝试从上面的链接下载tesseract-ocr并像我刚才解释的那样离线执行安装。 从来 ...
  • 它似乎可行。 关于针对ARM的交叉编译tesseract-ocr的这个错误报告以一种解决方法结束,声称它可以从那里开始工作: http : //code.google.com/p/tesseract-ocr/issues/detail?id = 262 It does seem doable. This bug report on cross compiling tesseract-ocr for ARM ends with a workaround and the claim that it works ...
  • 如果有这样的限制,你的形象肯定不在它附近。 我认为剩下的文字太过分了。 尝试手动纠正剩余的文本 - 并保持图像的其余部分不变。 虽然tesseract甚至可以在更高的倾斜角度下工作,但是每个段落(在你的例子中)偏斜变化的事实可能会使它偏离最后一个。 If there is such a limitation, your image is definitely nowhere near it. I think the remaining text is simply too skewed. Try manua ...

相关文章

更多

最新问答

更多
  • 您如何使用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)