File: pandas.py

package info (click to toggle)
python-petl 1.7.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,224 kB
  • sloc: python: 22,617; makefile: 109; xml: 9
file content (24 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import division, print_function, absolute_import


# todataframe()
###############

import petl as etl
table = [('foo', 'bar', 'baz'),
         ('apples', 1, 2.5),
         ('oranges', 3, 4.4),
         ('pears', 7, .1)]
df = etl.todataframe(table)
df


# fromdataframe()
#################

import petl as etl
import pandas as pd
records = [('apples', 1, 2.5), ('oranges', 3, 4.4), ('pears', 7, 0.1)]
df = pd.DataFrame.from_records(records, columns=('foo', 'bar', 'baz'))
table = etl.fromdataframe(df)
table