简体   繁体   中英

Columns from csv file not appearing in pandas dataframe in Python

I'm trying to work with a csv file in pandas but for some reason, pandas doesn't consider several of the columns to be actual columns. This is a snapshot of the dataframe:

在此处输入图像描述

But when I type df.info() , "Actb," "Foxp3," and "Odc1" don't appear:

<class 'pandas.core.frame.DataFrame'>
Int64Index: 268 entries, 334 to 20459
Data columns (total 9 columns):
 #   Column                  Non-Null Count  Dtype  
---  ------                  --------------  -----  
 0   Unnamed: 0              268 non-null    object 
 1   orig.ident              268 non-null    object 
 2   nCount_RNA              268 non-null    int64  
 3   nFeature_RNA            268 non-null    int64  
 4   mouse.percent.mt        268 non-null    float64
 5   MT_genes                268 non-null    int64  
 6   groups                  268 non-null    object 
 7   integrated_snn_res.0.8  268 non-null    int64  
 8   seurat_clusters         268 non-null    object 
dtypes: float64(1), int64(4), object(4)
memory usage: 29.0+ KB

Why might this be, and how can I fix it?

For reference, I've also looked in the csv file and I can't spot anything immediately wrong, or even different about those columns relative to all the others:

"","orig.ident","nCount_RNA","nFeature_RNA","mouse.percent.mt","MT_genes","Actb","Foxp3","Odc1","groups","integrated_snn_res.0.8","seurat_clusters"
"AAACCTGAGAGGGATA-1_1","CTRL",8976,2686,0.913547237076649,82,148,0,1,"CTRL","4","4"
"AAACCTGAGCTTTGGT-1_1","CTRL",4010,1567,0.57356608478803,23,45,0,5,"CTRL","7","7"
"AAACCTGAGGACAGAA-1_1","CTRL",6333,2249,1.59482078004105,101,89,0,4,"CTRL","4","4"
"AAACCTGAGGATGCGT-1_1","CTRL",9902,2474,1.22197535851343,121,121,0,1,"CTRL","18","18"
"AAACCTGAGTGAAGAG-1_1","CTRL",3182,1381,0.408548082966688,13,13,0,0,"CTRL","7","7"

If someone could provide some help, I would be extremely appreciative.

Could you please check the version of pandas you are using? I am using the 1.2.4 version and the df.info showed me all the columns.

在此处输入图像描述

You could also try to use the verbose option to the info:

  • For pandas >= 1.2.0: df.info(verbose=True, null_counts=True)
  • For pandas <1.2.0: df.info(verbose=True, null_counts=True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM