| Line 9: |
Line 9: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | == DataSeries == | + | ==DataSeries== |
| | <syntaxhighlight lang="python3"> | | <syntaxhighlight lang="python3"> |
| | s = pd.Series(['banana', 42]) | | s = pd.Series(['banana', 42]) |
| Line 17: |
Line 17: |
| | ==Dataframe== | | ==Dataframe== |
| | | | |
| − | === Create === | + | ===Create=== |
| | <syntaxhighlight lang="python3"> | | <syntaxhighlight lang="python3"> |
| | scientists = pd.DataFrame({ | | scientists = pd.DataFrame({ |
| Line 25: |
Line 25: |
| | 'Died': ['1958-04-16', '1937-10-16'], | | 'Died': ['1958-04-16', '1937-10-16'], |
| | }) | | }) |
| | + | </syntaxhighlight>If you want to keep the order of columns:<syntaxhighlight lang="python3"> |
| | + | scientists = pd.DataFrame({ |
| | + | 'Occupation': ['Chemist', 'Statistician'], |
| | + | 'Born': ['1920-07-25', '1876-06-13'], |
| | + | 'Died': ['1958-04-16', '1937-10-16'], |
| | + | }, index='Name': ['Rosaline Franklin', 'William Gosset'], columns=['Occupation', 'Born', ''Died']) |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | === From CSV === | + | ===From CSV=== |
| | <syntaxhighlight lang="python3"> | | <syntaxhighlight lang="python3"> |
| | news = pd.read_csv('news_2019.05.10.csv') | | news = pd.read_csv('news_2019.05.10.csv') |