English 中文(简体)
如何阅读 Csv 而不在熊猫页眉
原标题:How to read csv without header in pandas
I use Adj = pd.read_csv( xxxxxx.csv , usecols=["Adj Close"]) to read my csv file and result is looks like: Adj Close 0 0.007427 1 0.002013 2 0.008874 my csv file look like: Date Open High Low Close Volume Adj Close x x x x x 832.349976 x x x x x 832.349923 I trying to get the result like: 0 0.007427 or 0.007427 1 0.002013 0.002013 2 0.008874 0.008874 what should I do? Thanks!
问题回答
Try Adj = pd.read_csv( xxxxxx.csv , usecols=["Adj Close"])[ Adj Close ].values That will ingest the csv, select the Adj Close column, and then select the underlying numpy array.
It should be something like: Adj = pd.read_csv( xxxxxx.csv , usecols=["Adj Close"], header=False)
To read a csv file without header, do as follows: data = pd.read_csv(filepath, header=None) As EdChum commented, the questions isn t clear. But this is the first google result when searching for reading a csv file without header. So, I ve added a solution for that, in case somebody else lands here looking for a solution for that.




相关问题
Curve fitting with lmfit for Mossbauer spectroscopy

Im pretty new to lmfit and I keep running into this error. My dataset is pretty large ~27000 points of data from I gather: my error msg import numpy as np import matplotlib.pyplot as plt from lmfit ...

Python SocketServer: sending to multiple clients?

Well, I m trying to build a small python prgram with a SocketServer that is supposed to send messages it receives to all connected clients. I m stuck, I don t know how to store clients on the ...

Is there no mysql connector for python 2.7 on windows

While I see a bunch of links/binaries for mysql connector for python 2.6, I don t see one for 2.7 To use django, should I just revert to 2.6 or is there a way out ? I m using windows 7 64bit django ...

How to update the image of a Tkinter Label widget?

I would like to be able to swap out an image on a Tkinter label, but I m not sure how to do it, except for replacing the widget itself. Currently, I can display an image like so: import Tkinter as ...

PyScripter for Python 2.7

How to run PyScripter if you have Python 2.7 installed? There is a command line parameter for Pyscipter to tell it which pythonXX.dll to use, but I can t get this working.

How to set time limit on raw_input

in python, is there a way to, while waiting for a user input, count time so that after, say 30 seconds, the raw_input() function is automatically skipped?

热门标签