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 += '¤cyPair=' + 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)
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 += '¤cyPair=' + 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
最满意答案
它似乎可行。 关于针对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
相关问答
更多-
python怎么安装tesseract-ocr[2022-04-26]
一、需要的软件 1、pytesseract 2、PIL或者是pillow都可以 3、tesseract-ocr 第一、二两个都可以通过pip安装,第三个百度就可以找到。 二、使用方法 1.先用PIL打开图片 2.调用pytesseract的image_to_string()方法即可,简单吧! -
如何在图像上定义区域并传递给tesseract-ocr?(How to define regions on an image and pass to tesseract-ocr?)[2023-04-26]
我发现了如何将图像上的区域传递给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-ocr的区别与联系[2022-09-10]
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-OCR和OpenCV进行土耳其文字符识别(Turkish character recognition using Tesseract-OCR and OpenCV)[2023-04-18]
以下是在图像上使用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 ...
-
Pip install tesseract-ocr:退出状态为2失败(Pip install tesseract-ocr : failed with exit status 2)[2023-09-11]
考虑使用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-ocr输出是否有字符或文件大小限制?(Is there a character or file size limit for tesseract-ocr output?)[2023-10-13]
如果有这样的限制,你的形象肯定不在它附近。 我认为剩下的文字太过分了。 尝试手动纠正剩余的文本 - 并保持图像的其余部分不变。 虽然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 ...