(Feb-26-2018, 12:27 AM)snippsat Wrote: After version pandas 0.19.2 --> it can read directly from url.
You can mess withio.StringIO
before,but you should really upgrade.
If use Anaconda:
conda update conda conda update anaconda>>> import pandas as pd >>> pd.__version__ '0.20.3'G:\Anaconda3 λ python -m ptpython >>> import pandas as pd ... ... url = "http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data" ... the_names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class'] ... dataset = pd.read_csv(url, names=the_names) >>> dataset sepal-length sepal-width petal-length petal-width class 0 5.1 3.5 1.4 0.2 Iris-setosa 1 4.9 3.0 1.4 0.2 Iris-setosa 2 4.7 3.2 1.3 0.2 Iris-setosa 3 4.6 3.1 1.5 0.2 Iris-setosa 4 5.0 3.6 1.4 0.2 Iris-setosa 5 5.4 3.9 1.7 0.4 Iris-setosa 6 4.6 3.4 1.4 0.3 Iris-setosa
Yes, as I said in my initial posting reading from a URL works fine.
That was not the problem I posted I am trying to solve. :)
My issue is that our application POSTs the data from another application to a Flask web service. I need a way to figure out how to get the POSTed data (in a variable) into the Pandas data set. From my original posting, I cannot find a compatible "read" method that can read a variable into a Pandas dataset.
So, how do you get CSV data, in a variable, (not in a URL, for example) into a Pandas dataset?
In the screenshot below, I tried to use the io.StringIO method, but that still throws 500 errors.
I also tried to just read in the data like pd.DataFrame(.....), but couldn't get the syntax correct.
Thanks,