import pandas as pd
a = pd.read_csv('input.csv')
a.to_csv('output.csv', index=False)
"Merge" two data CSV files that
import pandas as pd
a = pd.read_csv('file1.csv')
b = pd.read_csv('file2.csv')
a = a.merge(b, on="CommonColumn", how="outer")
a.to_csv('output.csv', index=False)
Notes:
how
determines how the merge is performed. See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.merge.html"Merge" two data CSV files that
import pandas as pd
a = pd.read_csv('file1.csv')
b = pd.read_csv('file2.csv')
# Introduce a new column 'DataSource', if necessary, to indicate the source of the entry
a['DataSource'] = 'file1'
b['DataSource'] = 'file2'
merged_data = pd.DataFrame()
merged_data = merged_data.append(a, ignore_index=True, sort=False)
merged_data = merged_data.append(b, ignore_index=True, sort=False)
merged_data.to_csv('output.csv', index=False)
d = {
'Name': ['Alice', 'Bob'],
'Math': [100, 90],
'English': [80, 85],
}
df = pd.DataFrame(data=d)
"""
Name Math English
0 Alice 100 80
1 Bob 90 85
"""
# Add a new column to all rows
df['Class'] = 'ClassA'
# Adda new column based on other columns
df['Avg'] = df.apply(lambda row: (row['Math'] + row['English']) / 2, axis=1)
quick-ref
{%hackmd BJrTq20hE %} Context Given a system that contains $N$ unknown states, whose values at time $k$ are denoted as $$ \mathbf{x}_k \in \mathbb{R}^N $$ We want to know the values of $\mathbf{x}_k$, but we were unable to directly observe $\mathbf{x}_k$. What we have is a noisy observation $\mathbf{z}_k \in \mathbb{R}^N$ for any time $k$.
Nov 21, 2021{%hackmd BJrTq20hE %} Overview Consider a system that consists of array of $n$ arbitrary sensors, the steering vector of the senor array represents the phase delays, with respect to a reference position, for an incoming plane wave at each sensor element. The phase delay for i-th senor is defined as $$ \exp( -j 2 \pi \frac{\tau_i}{T} ) $$
Nov 21, 2021{%hackmd BJrTq20hE %} Terminologies Function v.s. Method: Function Method Independent of any object Associated to an object
Aug 26, 2021{%hackmd BJrTq20hE %} Common diff options --numstat Shows number of added and deleted lines --name-only Show only names of changed files. --name-status Show only names and status of changed files. See the description of the --diff-filter option on what the status letters mean. --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
Aug 20, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up