1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| >>> import pandas as pd >>> from pandas import Series, DataFrame
>>> data = {"name":["yahoo","google","facebook"], "marks":[200,400,800], "price":[9, 3, 7]} >>> f1 = DataFrame(data) >>> f1 marks name price 0 200 yahoo 9 1 400 google 3 2 800 facebook 7
>>> f2 = DataFrame(data, columns=['name','price','marks']) >>> f2 name price marks 0 yahoo 9 200 1 google 3 400 2 facebook 7 800
>>> f3 = DataFrame(data, columns=['name', 'price', 'marks', 'debt'], index=['a','b','c']) >>> f3 name price marks debt a yahoo 9 200 NaN b google 3 400 NaN c facebook 7 800 NaN
>>> newdata = {"lang":{"firstline":"python","secondline":"java"}, "price":{"firstline":8000}} >>> f4 = DataFrame(newdata) >>> f4 lang price firstline python 8000 secondline java NaN
|