python
#Open file
path=""
filename="hoge"
df = pd.read_csv('{}/{}.csv'.format(path,filename))
This is recommended because it is simpler and easier to understand. I asked @shiracamus to teach me.
python
#Open file
path=""
filename="hoge"
df = pd.read_csv(f'{path}/{filename}.csv')
python
#Save file
path=""
filename="hoge"
df.to_csv('{}/{}.csv'.format(path,filename), index=False)
Similarly, this is recommended because it is simpler and easier to understand. I asked @shiracamus to teach me.
python
#Save file
path=""
filename="hoge"
df.to_csv(f'{path}/{filename}.csv', index=False)
python
line = df.shape[0] #line
row = df.shape[1] #Column
python
hoge = df.iat[i, j]
python
list=[hoge1,hoge2,hoge3]
df = pd.DataFrame(list, columns=["hoge"])
python
df = pd.concat([df1, df2], axis=1) #Vertical:0 sideways:1
python
hoge = df.iat[0, j]
python
line = df.shape[0] #line
hoge = df.iat[line, j]
python
df = df.set_index('Column name')
index returns to 1,2,3 ..., and the column specified in index returns to its original position?
python
df = df.reset_index('Column name')
If you specify a new column name, the column will be added, and if it is an existing column name, it will be overwritten.
python
df["Column name"] = pd.to_datetime(df["Column name"])
If you specify a new column name, the column will be added, and if it is an existing column name, it will be overwritten.
python
df["Column name"] = df["Column name"].to_string()
Recommended Posts