0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

はじめに

移植やってます。
( from python 3.7 to ruby 2.7 )

pandas (Python)

import pandas as pd

val = [[1,2,3],[4,5,6],[7,8,9]]
df = pd.DataFrame.new(val, index=[0,2,4], colums=['d','e','f'])

print(df)
print(df.loc[2])
print(df.iloc[2])
print(df['e'])

現場で使える!pandasデータ前処理入門 機械学習・データサイエンスで役立つ前処理手法 - 148p

どうすRuby

require 'pandas'

val = [[1,2,3],[4,5,6],[7,8,9]]
df = Pandas.DataFrame.new(val, index=[0,2,4], colums=['d','e','f'])

puts df
puts df.loc[2]
puts df.iloc[2]
puts df['e']

# output
   d  e  f
0  1  2  3
2  4  5  6
4  7  8  9
d    4
e    5
f    6
Name: 2, dtype: int64
d    7
e    8
f    9
Name: 4, dtype: int64
0    2
2    5
4    8
Name: e, dtype: int64

RubyGemspandasがありますので、同様のことは可能です。
しかしながら、newを付ける必要があることは、ググってもなかなか見つからないようです。

メモ

  • Python の pandas を学習した
  • 百里を行く者は九十里を半ばとす
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?