I write it a lot, but for some reason I can't remember it, so I've put together the code that I google every time.
Python
if __name__ == '__main__':
print('Hello World!')
import warnings
warnings.filterwarnings('ignore')
#Save
with open('list.txt', 'w') as f:
print(*list_obj, sep='\n', file=f)
#Read
with open('list.txt') as f:
list_obj = f.read().splitlines()
# list_obj = list(map(lambda x: x.split(','), list_obj)) #For two or more dimensions
list = [i for i in list if 'hogehoge' in i]
from tqdm import tqdm
# jupyter notebook
from tqdm import tqdm_notebook as tqdm
import pandas as pd
pd.set_option('display.max_rows', None)
import pandas as pd
pd.set_option('display.max_colwidth', 1000)
fig = plt.figure(figsize=(20, 10))
Bar Plot
plt.bar(df.index, df['value'], align='center')
plt.xticks(df.index, df.index)
t = 'abc/def'
print(t.split('/')[0]) # abc
print(t.split('/')[1]) # def
#If there is no specified character when mapping to the matrix, an error will be thrown, so it is better to map with the following function.
def pick_char(t):
try:
return t.split('/')[0]
except IndexError:
return t
df.map(pick_char)
t = '\n\t\r\u3000 abc \u3000\r\t\n'
print(t.strip()) # abc
$ pip install --no-cache-dir <Library>
Reinstall with -I
git
$ git rm -r --cached .
$ chown -R $USER <dir>
I will add it as soon as I encounter a convenient character string operation.
Recommended Posts