csv 读取一列中的所有行 Pandas

csv read all row in a column Pandas

晚上好 我试图通过 pandas 读取一个 csv 文件,但是当我显示我的数据框时,我发现整行都在一列中,它在列之间没有分隔 这是结果:

这是我的代码:

import pandas as pd

data = pd.read_csv("data/dd.csv",delimiter= ',', engine="python", encoding='ISO-8859-1')

我希望我的数据框采用这种形式:

这是我的样本:

"Report ID, ""Drug Identification Number"", ""Report Type"", ""Brand name"", ""Company Name"", ""Common or Proper name"", Ingredients, Strength(s), ""Packaging size"","" Route of administration"", ""Shortage status"", ""Dosage form(s)"", ""ATC Code"", ""ATC description"", ""Anticipated start date"", ""Actual start date"", ""Estimated end date"", ""Actual end date"", Reason, ""Date Created"", ""Date Updated"", ""Tier 3""     "
"34506,01924303,Shortage,""0.9% SODIUM CHLORIDE INJECTION USP"",""B. BRAUN MEDICAL INC"",""Sodium Chloride"",""SODIUM CHLORIDE"",0.9%,""100mL, 150mL, 250mL, 500mL"",INTRAVENOUS,Resolved,SOLUTION,B05XA,""I.V. SOLUTION ADDITIVES"",2017-12-22,2017-12-22,,2019-01-01,""Disruption of the manufacture of the drug."",2018-01-02,2019-11-06,No      "
"28240,01963937,Shortage,""0.9% SODIUM CHLORIDE IRRIGATION USP"",""B. BRAUN MEDICAL INC"",""Sodium Chloride"",""SODIUM CHLORIDE"",0.9%,""500mL, 1000mL, 2000mL, 4000mL"",IRRIGATION,""Actual shortage"",SOLUTION,B05CB,""IRRIGATING SOLUTIONS"",,2017-11-03,,,""Requirements related to complying with good manufacturing practices."",2017-11-06,2019-04-04,No     "
"43080,00436208,Shortage,""2% LIDOCAINE HYDROCHLORIDE INJECTION USP"",""HOSPIRA HEALTHCARE CORPORATION"",""LIDOCAINE HYDROCHLORIDE LIFESHIELD"",""LIDOCAINE HYDROCHLORIDE"",20MG,""10 x 5mL"",INTRAVENOUS,Resolved,SOLUTION,C01BB,""ANTIARRHYTHMICS, CLASS I AND III"",2018-04-13,,2018-07-13,2018-07-02,""Disruption of the manufacture of the drug."",2018-03-16,2018-07-03,No        "
"51084,00436208,Shortage,""2% LIDOCAINE HYDROCHLORIDE INJECTION USP"",""HOSPIRA HEALTHCARE CORPORATION"",""LIDOCAINE HYDROCHLORIDE ANSYR"",""LIDOCAINE HYDROCHLORIDE"",20MG,""10 x 5mL"",INTRAVENOUS,Resolved,SOLUTION,C01BB,""ANTIARRHYTHMICS, CLASS I AND III"",,2018-06-29,,2018-07-31,""Disruption of the manufacture of the drug."",2018-06-01,2018-08-01,No       "
"24792,02141450,Shortage,""20% PROSOL"",""BAXTER CORPORATION"",""20% PROSOL"",""PHENYLALANINE       "
"49014,02248489,Shortage,""4% ASTRACAINE DENTAL WITH EPINEPHRINE 1:200,000 (0.005MG/ML)"",""DENTSPLY CANADA LIMITED"",""articaine HCl with epinephrine"",""ARTICAINE HYDROCHLORIDE      "
" EPINEPHRINE"",""40MG      "
" 0.005MG"",""100 1.8 mL cartridges/box"",BLOCK/INFILTRATION,Resolved,SOLUTION,N01BB,""ANESTHETICS, LOCAL"",2018-05-10,2018-05-10,2018-07-16,2018-06-15,""Disruption of the manufacture of the drug."",2018-05-10,2018-06-19,No     "
"27274,02248489,Shortage,""4% ASTRACAINE DENTAL WITH EPINEPHRINE 1:200,000 (0.005MG/ML)"",""DENTSPLY CANADA LIMITED"",""Articaine Hydrochloride 40 mg/mL and Epinephrine Injection 1:200,000"",""ARTICAINE HYDROCHLORIDE        "
" EPINEPHRINE"",""40MG      "

我从这个网站下载 csv 文件:

web site Drug Shortages canada

当我下载示例数据时,我得到的文件如下所示:

"Discontinuation reports","DISCLAIMER: The information found within this file is presented in the language in which it was written and submitted."
"Report ID","Drug Identification Number","Report Type","Brand name","Company Name","Common or Proper name",Ingredients,Strength(s),"Packaging size","Route of administration","Discontinuation status","Dosage form(s)","ATC Code","ATC description","Discontinuation date","Anticipated discontinuation date",Reason,"Date Created","Date Updated","Tier 3"
156691,02239653,Discontinuation,ANDRODERM,"ALLERGAN INC","Testosterone Transdermal Patch,",TESTOSTERONE,2.5MG,30s,"TRANSDERMAL
TRANSDERMAL",Discontinued,PATCH,G03BA,ANDROGENS,2022-03-10,,"Business reasons",2022-03-14,2022-03-14,No
...

请注意,第一“行”是元数据,必须丢弃:

print(pandas.read_csv("discontinuation_report_export.csv", skiprows=1).head())

给我:

   Report ID  Drug Identification Number      Report Type           Brand name            Company Name  ... Anticipated discontinuation date            Reason Date Created Date Updated Tier 3
0     156691                     2239653  Discontinuation            ANDRODERM            ALLERGAN INC  ...                              NaN  Business reasons   2022-03-14   2022-03-14     No
1     154571                      755885  Discontinuation  APO-PINDOL TAB 10MG              APOTEX INC  ...                              NaN  Business reasons   2022-02-09   2022-02-10     No
2     154574                      755893  Discontinuation  APO-PINDOL TAB 15MG              APOTEX INC  ...                       2022-06-03  Business reasons   2022-02-09   2022-02-09     No
3     154568                      755877  Discontinuation   APO-PINDOL TAB 5MG              APOTEX INC  ...                              NaN  Business reasons   2022-02-09   2022-02-10     No
4     153603                     2448610  Discontinuation             BYDUREON  ASTRAZENECA CANADA INC  ...                       2022-03-31  Business reasons   2022-01-26   2022-01-28     No

[5 rows x 20 columns]