トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

PRG-PY-pandas

CSV の読み込み

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import pandas as pd 

df_names = pd.read_csv('lds9d1.csv', names=('xa','ya','za', 'xg','yg','zg', 'xm', 'ym', 'zm','ROLL','PITCH','YAW', 'degX','degY','DUM'))

print(df_names)

Excel ファイルの読み込み

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import pandas as pd

# df_names = pd.read_csv('corona-kanjajokyou.csv',names=('n0','n1','n2','n3'))
df = pd.read_excel('corona-kanjajokyou.xlsx')

print('dataframeの行数・列数の確認==>\n', df.shape)
print('indexの確認==>\n', df.index)
print('columnの確認==>\n', df.columns)
print('dataframeの各列のデータ型を確認==>\n', df.dtypes)

print(df)

index の指定

import pandas as pd
### df_names = pd.read_csv('lds9d1.csv', names=('xa','ya','za', 'xg','yg','zg', 'xm', 'ym', 'zm','ROLL','PITCH','YAW', 'degX','degY','DUM'))
df1 = pd.read_csv('./D/30.csv',index_col=0)
df2 = pd.read_csv('./D/31.csv',index_col=0)

# df1.columns = ['host', 'count', 'byte']
# df2.columns = ['host', 'count', 'byte']

astype(int) のエラー

# df1['byte']=df1['response_bytes_clf'].astype(int)
df1['byte']=pd.to_numeric(df1['response_bytes_clf'],errors='coerce')

Tips

https://qiita.com/ysdyt/items/9ccca82fc5b504e7913a

https://qiita.com/koara-local/items/0e56bc1e58b11e4d7a32