Help us understand the problem. What is going on with this article?

データフレーム の扱い方

import pandas as pd
import numpy as np

csvファイルを読み込む

df=pd.read_csv('〜〜〜.csv',header=None,names=('name', 'id'))

names=〜〜でカラム名を指定。
header=Noneで一行目をheaderと認識しないようにしている。

データの一部を置換する

df=df.replace('A B', 'エー ビー')
df=df.replace('B A', 'ビー エー')

dfの一つのカラムの中のテキストを分割して新たに2つのカラムにする

df2 = pd.concat([df, df['name'].str.split(' ', expand=True)], axis=1).drop('name', axis=1)

dfの複数の列を取り出す

df=df.loc[:,["列名","列名","列名"]]

dfどうしを縦に結合する

df3=pd.concat([df1, df2])

重複した行を削除する

df=df[~df.duplicated()]

条件を満たす行を取り出す

df[df["列名"]=="~~"]

dataframeをリストにする

df_list=df.values.tolist()

列のリストをarrayにする

df_list=np.array(df['列名'])
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした