如何通过指定列名来获取所需的列数据

时间:2018-05-08 12:08:29

标签: python pandas dataframe

我有以下代码,

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
dataFileName='RFInput.xlsx'
sheetName='Rawdata'
sheetNamePara='paraList'
dataRaw=pd.read_excel(dataFileName, sheetname = sheetName)
datapara=pd.read_excel(dataFileName, sheetname = sheetNamePara)

noData=len(dataRaw)
import matplotlib.pylab as plt
from sklearn.cross_validation import train_test_split
from sklearn.cross_validation import cross_val_score
from sklearn.preprocessing import StandardScaler


labels = datapara
x = dataRaw[labels]
y = dataRaw['classVariable']

我在datapara中指定了所需的列名,但是它将所有值都读为NaN

1 个答案:

答案 0 :(得分:0)

目前,<DataTrigger Binding="{Binding HasItems, RelativeSource={RelativeSource Self}}" Value="false"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DataGrid"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/> <TextBlock Text="No data..." Grid.Row="1" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> 指的是数据框。要选择多个列,您需要在标签中指定一个列表,如下所示:

labels