Ad
How To Convert Array To Dataframe In Column Only
i have tried to convert array to dataframe, and follow the documentation how to convert them.
here my script;
M = pd.DataFrame(a, columns=col)
c0 = M.quantile(0)
c1 = M.quantile(0.2)
c2 = M.quantile(0.4)
c3 = M.quantile(0.6)
c4 = M.quantile(0.8)
c5 = M.quantile(1)
d = np.array([c0,c1,c2,c3,c4,c5])
output_table_1 = pd.DataFrame(d)
the ouput has 6 rows, is not my expected that i want convert it to 6 columns. anyone can help me to solve this issue?
Ad
Answer
Check the shape
of d
:
In [186]: d.shape
Out[186]: (6, 1)
In [187]: pd.DataFrame(d)
Out[187]:
0
0 0.0
1 0.6
2 1.2
3 1.8
4 2.4
5 3.0
With a (1,6) shape:
In [188]: pd.DataFrame(d.T)
Out[188]:
0 1 2 3 4 5
0 0.0 0.6 1.2 1.8 2.4 3.0
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad