コード例 #1
0
ファイル: examples.py プロジェクト: datamade/petl
f(s)
g = nthword(1)
g(s)


# search
table1 = (('foo', 'bar', 'baz'),
          ('orange', 12, 'oranges are nice fruit'),
          ('mango', 42, 'I like them'),
          ('banana', 74, 'lovely too'),
          ('cucumber', 41, 'better than mango'))

from petl import search, look
look(table1)
# search any field
table2 = search(table1, '.g.')
look(table2)
# search a specific field
table3 = search(table1, 'foo', '.g.')
look(table3)


# addcolumn

table1 = (('foo', 'bar'),
          ('A', 1),
          ('B', 2))

from petl import addcolumn, look
look(table1)
col = [True, False]
コード例 #2
0
ファイル: examples.py プロジェクト: aklimchak/petl
f(s)
g = nthword(1)
g(s)


# search
table1 = (('foo', 'bar', 'baz'),
          ('orange', 12, 'oranges are nice fruit'),
          ('mango', 42, 'I like them'),
          ('banana', 74, 'lovely too'),
          ('cucumber', 41, 'better than mango'))

from petl import search, look
look(table1)
# search any field
table2 = search(table1, '.g.')
look(table2)
# search a specific field
table3 = search(table1, 'foo', '.g.')
look(table3)


# addcolumn

table1 = (('foo', 'bar'),
          ('A', 1),
          ('B', 2))

from petl import addcolumn, look
look(table1)
col = [True, False]
コード例 #3
0
df.fillna(0)
#fill nan value to 0
df['freight_cost'] = df['freight_cost'].fillna(0)

df['freight_cost'].count()
"""

msk = np.random.rand(len(df)) < 0.8
train = df[msk]
test = df[~msk]
test_new = test.drop('freight_cost', axis=1)
y_test = np.log1p(test["freight_cost"])
train = train[train.price != 0].reset_index(drop=True)


nrow_train = train.shape[0]
y = np.log1p(train["freight_cost"])
merge: pd.DataFrame = pd.concat([train, test_new])
"""

import petl as etl

table1 = [['foo', 'bar', 'baz'], ['orange', 12, 'oranges are nice fruit'],
          ['mango', 42, 'I like them'], ['banana', 74, 'lovely too'],
          ['cucumber', 41, 'better than mango']]

# Regular expression search to find any field having g letter in it
table2 = etl.search(table1, '.g')
print(table2)
コード例 #4
0
ファイル: regex.py プロジェクト: DeanWay/petl
          ['4', 'tempd2', '19']]
table2 = etl.split(table1, 'variable', 'd', ['variable', 'day'])
table2


# search()
##########

import petl as etl
table1 = [['foo', 'bar', 'baz'],
          ['orange', 12, 'oranges are nice fruit'],
          ['mango', 42, 'I like them'],
          ['banana', 74, 'lovely too'],
          ['cucumber', 41, 'better than mango']]
# search any field
table2 = etl.search(table1, '.g.')
table2
# search a specific field
table3 = etl.search(table1, 'foo', '.g.')
table3


# searchcomplement()
####################

import petl as etl
table1 = [['foo', 'bar', 'baz'],
          ['orange', 12, 'oranges are nice fruit'],
          ['mango', 42, 'I like them'],
          ['banana', 74, 'lovely too'],
          ['cucumber', 41, 'better than mango']]
コード例 #5
0
ファイル: regex.py プロジェクト: trb116/pythonanalyzer
import petl as etl
table1 = [['id', 'variable', 'value'], ['1', 'parad1', '12'],
          ['2', 'parad2', '15'], ['3', 'tempd1', '18'], ['4', 'tempd2', '19']]
table2 = etl.split(table1, 'variable', 'd', ['variable', 'day'])
table2

# search()
##########

import petl as etl
table1 = [['foo', 'bar', 'baz'], ['orange', 12, 'oranges are nice fruit'],
          ['mango', 42, 'I like them'], ['banana', 74, 'lovely too'],
          ['cucumber', 41, 'better than mango']]
# search any field
table2 = etl.search(table1, '.g.')
table2
# search a specific field
table3 = etl.search(table1, 'foo', '.g.')
table3

# searchcomplement()
####################

import petl as etl
table1 = [['foo', 'bar', 'baz'], ['orange', 12, 'oranges are nice fruit'],
          ['mango', 42, 'I like them'], ['banana', 74, 'lovely too'],
          ['cucumber', 41, 'better than mango']]
# search any field
table2 = etl.searchcomplement(table1, '.g.')
table2