Putting data together

Finally, pandas DataFrames can be created by merging series or other list-like data. Note that scalars are transformed into lists, as follows:

In: import pandas as pd    my_own_dataset = pd.DataFrame({'Col1': range(5),                                    'Col2': [1.0]*5,                                    'Col3': 1.0,                                    'Col4': 'Hello World!'})    my_own_dataset

Here is the output for my_own_dataset:

It can be easily said that for each of the columns you want to be stacked together, you provide their names (as the dictionary key) and values (as the dictionary value for that key). As seen in the preceding example, Col2 and Col3 are created in two different ways, but they provide the same resulting ...

Get Python Data Science Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.