我正在尝试从共享相同列名称的不同 .csv 文件收集数据。但是,某些 csv 文件的标题位于不同的行中。
有没有办法根据包含“大多数”值(实际标题名称)的第一行动态确定标题行?
我尝试了以下方法:
def process_file(file, path, col_source, col_target):
global df_master
print(file)
df = pd.read_csv(path + file, encoding = "ISO-8859-1", header=None)
df = df.dropna(thresh=2) ## Drop the rows that contain less than 2 non-NaN values. E.g. metadata
df.columns = df.iloc[0,:].values
df = df.drop(df.index[0])
Run Code Online (Sandbox Code Playgroud)
但是,当使用 时pandas.read_csv(),似乎第一个值决定了实际数据帧的大小,因为我收到以下错误消息:
pandas.errors.ParserError:标记数据时出错。C 错误:第 4 行应有 1 个字段,结果为 162
正如您在本例中看到的,标题行将位于第 4 行。添加error_bad_lines=False到 read_csv 时,只有元数据会被读入数据帧。
这些文件可以具有以下结构:
一个“普通”文件:
row1 col1 col2 col3 col4 col5
row2 val1 val1 val1 val1 val1
row3 val2 …Run Code Online (Sandbox Code Playgroud) 有没有办法使用ALTER TABLE命令一次在 Oracle 中添加多个约束?我知道使用 SQL 服务器是可能的。
ALTER TABLE l_customer_order
ADD CONSTRAINT pk_l_customer_order
PRIMARY KEY (customer_order_id_hk),
CONSTRAINT fk_customer_id_hk
FOREIGN KEY (customer_id_hk)
REFERENCES h_customers(customer_id_hk)
ON DELETE CASCADE,
CONSTRAINT fk_order_id_hk
FOREIGN KEY (order_id_hk)
REFERENCES h_orders(order_id_hk)
ON DELETE CASCADE;
Run Code Online (Sandbox Code Playgroud)
错误信息:
Error report -
ORA-01735: invalid ALTER TABLE option
01735. 00000 - "invalid ALTER TABLE option"
*Cause:
*Action:
Run Code Online (Sandbox Code Playgroud) I want to implement a button that automatically scrolls to a specific div id="contactMe", which is located on the same page. I am using vue.js.
I tried the following method with native js.
<input
onClick="document.getElementById('contactMe').scrollIntoView();"
type="submit"
class="cta-button bg-yellow mt-8 flex justify-center"
:value="$frontmatter.contactFormButton"
/>
Run Code Online (Sandbox Code Playgroud)
However, I receive the following error in my console.
Uncaught TypeError: Cannot read property 'scrollIntoView' of null at HTMLInputElement.onclick ((index):1)
What is the right command in the vue framework?