任何人都可以解释评论='#'如何在pandas中的csv文件中运行
<rewrite>
<!--This directive was not converted because it is not supported by IIS: RewriteBase /.-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^index\.html" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="OPTIONSVerbHandler" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
答案 0 :(得分:2)
以下是comment
参数如何工作的示例:
csv_string = """col1;col2;col3
1;4.4;99
#2;4.5;200
3;4.7;65"""
# Without comment argument
print(pd.read_csv(StringIO(csv_string), sep=";"))
# col1 col2 col3
# 0 1 4.4 99
# 1 #2 4.5 200
# 2 3 4.7 65
# With comment argument
print(pd.read_csv(StringIO(csv_string),
sep=";", comment="#"))
# col1 col2 col3
# 0 1 4.4 99
# 1 3 4.7 65
答案 1 :(得分:1)
您可以在文档中找到所有内容。
引用:
comment
:str
,默认None
表示不应解析行的剩余部分。如果在行的开头找到,则该行将被完全忽略。此参数必须是单个字符。与空行一样(只要
skip_blank_lines=True
),参数header
将忽略完全注释的行,但skiprows
不会忽略。例如,如果comment='#'
,使用#emptyna,b,cn1,2,3
解析header=0
将导致a,b,c
被视为标题。
因此,它只是忽略#
之后的所有内容,直到新行或header
。