Tage 1 und 2 zum Erstellen eines Formatierungswerkzeugs für Betriebsprotokolle
RuntimeError: The current Numpy installation (Unterlassung) fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86
Untersuchen Sie die Ursache von.
Weitere Informationen finden Sie unten.
https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html
use numpy==1.19.3 works
?
https://qiita.com/bear_montblanc/items/b4b75dfd77da98076da5 Wenn Sie dies googeln Ich weiß nicht viel darüber, woran ich glaube, aber ich werde es einfach versuchen → Der Fehler ist verschwunden. Eh.
https://note.nkmk.me/python-pandas-sort-values-sort-index/ Zurücksenden an. Gemäß dem Tutorial
firstpandas.py
import pandas as pd
df = pd.read_csv('sample_pandas_normal.csv', index_col=0)
print(df)
Dann renne.
C:\workspaces\playground>firstpandas.py
age state point
name
Alice 24 NY 64
Bob 42 CA 92
Charlie 18 CA 70
Dave 68 TX 70
Ellen 24 CA 88
Frank 30 NY 57
Oh, das war es. Lassen Sie uns das sortieren. Ist es okay das zu tun?
firstpandas.py
import pandas as pd
df = pd.read_csv('sample_pandas_normal.csv', index_col=0)
df.sort_values('age')
print(df)
Infolgedessen ändert sich nichts. Es ist nicht gut, es mit einem Sinn zu tun. .. Zuallererst ist das offizielle Dokument hier https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html
Noch einmal. Als ich aus der Schlussfolgerung schrieb, gab mir dies ein Bild.
firstpandas.py
import pandas as pd
df = pd.read_csv('sample_pandas_normal.csv')
print(df)
df_s = df.sort_values('age')
print(df_s)
C:\workspaces\playground>firstpandas.py
name age state point
0 Alice 24 NY 64
1 Bob 42 CA 92
2 Charlie 18 CA 70
3 Dave 68 TX 70
4 Ellen 24 CA 88
5 Frank 30 NY 57
name age state point
2 Charlie 18 CA 70
0 Alice 24 NY 64
4 Ellen 24 CA 88
5 Frank 30 NY 57
1 Bob 42 CA 92
3 Dave 68 TX 70
Es ist eine gute Idee, die Python-Grammatik zu überprüfen
Python3 Cheet Sheet (Basic) Python Cheet Sheet-Grundelemente (@IT) Übersetzt den offiziellen Pandas-Spickzettel
Einmal hier.
Jetzt habe ich die verwendete CSV ein wenig geändert und die Datumsspalte hinzugefügt.
sample_pandas_date.csv
name,age,state,point,birthday
Alice,24,NY,64,1996/1/2
Bob,42,CA,92,1978/2/2
Charlie,18,CA,70,2002/3/4
Dave,68,TX,70,1952/1/1
Ellen,24,CA,88,1996/1/5
Frank,30,NY,57,1990/5/15
firstpandas.py
import pandas as pd
df = pd.read_csv('sample_pandas_date.csv')
print(df)
df_s = df.sort_values('birthday')
print(df_s)
Was damit passiert, liegt unter dem Ergebnis.
C:\workspaces\playground>firstpandas.py
name age state point birthday
0 Alice 24 NY 64 1996/1/2
1 Bob 42 CA 92 1978/2/2
2 Charlie 18 CA 70 2002/3/4
3 Dave 68 TX 70 1952/1/1
4 Ellen 24 CA 88 1996/1/5
5 Frank 30 NY 57 1990/5/15
name age state point birthday
3 Dave 68 TX 70 1952/1/1
1 Bob 42 CA 92 1978/2/2
5 Frank 30 NY 57 1990/5/15
0 Alice 24 NY 64 1996/1/2
4 Ellen 24 CA 88 1996/1/5
2 Charlie 18 CA 70 2002/3/4
Es wird so.
Es ist Zeit, das echte Betriebsprotokoll zu verwenden. Beim Eingeben der tatsächlichen CSV wurde eine Fehlermeldung angezeigt. Dies ist das Ende der Aufregung.
C:\workspaces\playground>firstpandas.py
Traceback (most recent call last):
File "C:\workspaces\playground\firstpandas.py", line 3, in <module>
df = pd.read_csv('oplog20201112.csv')
File "C:\Users\works\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 688, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\works\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 454, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\works\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 948, in __init__
self._make_engine(self.engine)
File "C:\Users\works\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 1180, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\works\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 2010, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas\_libs\parsers.pyx", line 537, in pandas._libs.parsers.TextReader.__cinit__
File "pandas\_libs\parsers.pyx", line 740, in pandas._libs.parsers.TextReader._get_header
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 0: invalid start byte