Created
July 2, 2019 05:15
-
-
Save adxrgh/2be4d9b955af404fcde6ce145516c4dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [12]: arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux']), | |
....: np.array(['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two'])] | |
....: | |
In [13]: s = pd.Series(np.random.randn(8), index=arrays) | |
In [14]: s | |
Out[14]: | |
bar one -0.861849 | |
two -2.104569 | |
baz one -0.494929 | |
two 1.071804 | |
foo one 0.721555 | |
two -0.706771 | |
qux one -1.039575 | |
two 0.271860 | |
dtype: float64 | |
In [15]: df = pd.DataFrame(np.random.randn(8, 4), index=arrays) | |
In [16]: df | |
Out[16]: | |
0 1 2 3 | |
bar one -0.424972 0.567020 0.276232 -1.087401 | |
two -0.673690 0.113648 -1.478427 0.524988 | |
baz one 0.404705 0.577046 -1.715002 -1.039268 | |
two -0.370647 -1.157892 -1.344312 0.844885 | |
foo one 1.075770 -0.109050 1.643563 -1.469388 | |
two 0.357021 -0.674600 -1.776904 -0.968914 | |
qux one -1.294524 0.413738 0.276662 -0.472035 | |
two -0.013960 -0.362543 -0.006154 -0.923061 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment