我有一张这样的桌子
   user         company company2 company3 company4
    1           Mac     Lenovo    Hp      null              
    2           Mac       MSI     Sony                          
Run Code Online (Sandbox Code Playgroud)
使用熊猫我希望它是
     user    company
     1          Mac
     1          Lenovo
     1          Hp
     2         Mac
Run Code Online (Sandbox Code Playgroud)
等等在这里我尝试了但是没有使用pandas pivot.
dataframe = pd.read_csv('data.csv')
dataframe.fillna(value='', inplace=True)
#dataframe.pivot(index='user', columns='company')
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用并给出错误.
我正在使用codeigniter控制器将数据推送到页面
public function trial(){
            /* after commiting now show them the next page which will directly allow them to invest */
                            $usertable =$this->user_profile->getUserTable();               
                            $userId = $usertable['ORIG_ID'];
                            $facebookId = $this->Facebook->getUser();
                            $sidebarData = array(
                                'userName' => $this->user_profile->getUserName(), 
                                'facebookId' => $facebookId, 
                                'caller' => 'investment_bucket'
                        );
                         $headerData = array(
                            $this->history->getPreviousPageInArray(),
                            'userName' => $this->user_profile->getUserName(),
                            'facebookId' => $facebookId 
                        );
                            $investAmount = 100;
                            $loanPeriod = 60;
           $investdata = array(
                                'investAmount' => $investAmount ,
                                'loanPeriod ' => $loanPeriod,
                                'pathName' => 'invest'
                            );
                            $this->load->view('header', $headerData);   
                            $this->load->view('borrower_sidebar_view', $sidebarData);
                            $this->load->view("invest_created_basket_view",$investdata);
                            $this->load->view('footer'); …Run Code Online (Sandbox Code Playgroud)