Comments (3)
what about df.T.melt()
? you can then either set_index
the variable
column or drop it altogether.
In [10]: df = pd.DataFrame({0: ['A1', 'A2', 'A3'], 1: ['B1', 'B2', 'B3'], 2: ['C1', 'C2', 'C3']})
In [11]: df
Out[11]:
0 1 2
0 A1 B1 C1
1 A2 B2 C2
2 A3 B3 C3
In [12]: df.T.melt()
Out[12]:
variable value
0 0 A1
1 0 B1
2 0 C1
3 1 A2
4 1 B2
5 1 C2
6 2 A3
7 2 B3
8 2 C3
from pandas.
Yep agree that this should solve the problem
from pandas.
I ended up finding out how to do this in the cudf test suite https://github.com/rapidsai/cudf/blob/branch-24.06/python/cudf/cudf/tests/test_reshape.py#L305 pd.Series(np.vstack(pdf.to_numpy()).reshape((-1,)))
which is much faster than df.T.melt()["value"]
. Thanks for tip though!
from pandas.
Related Issues (20)
- ENH: Consistent naming conventions for string dtype aliases HOT 17
- QST: loc returns matrix with one row when index is not strictly unique
- BUG: df.where(series, axis=1) always results in TypeError HOT 2
- BUG: incorrect aggregation of dataframe when using UDF with kwarg HOT 3
- BUG: Casting dtype of large datetime values raises an error inconsistent with resolution HOT 3
- BUG: Pandas does not recognise older missing value code for double when reading Stata files prior to 108 (Stata 6) format
- Potential regression induced by "PERF: Series(dict) returns RangeIndex when possible" HOT 1
- BUG: pd.isna handles np.nan inconsistently between numpy and extension / arrow types HOT 4
- BUG: pyarrow dictionary type ordered argument not respected HOT 2
- BUG: pd.sort_values() not working on categorical column HOT 2
- ENH: Support reading value labels for Stata formats 108 (Stata 6) and earlier
- BUG: True cannot be cast to bool HOT 6
- BUG: Segfault when calling df.to_json(orient='records') and numpy.datetime64 being serialized HOT 2
- test.tar file left over after running test suite HOT 1
- BUILD: C code coverage HOT 2
- BUG: Inputting a masked 64-bit integer array from numpy gets mangled by a hidden float conversion HOT 3
- ENH: DtypeWarning message enhancement HOT 2
- DOC: Documentation side navigation bar loses scroll position on option selection HOT 3
- ENH: Better error handling in `strftime` HOT 2
- ENH: consistent strftime behaviour
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas.