我想知道在使用Moshi时如何忽略Kotlin类字段.
我找到了这个Java(Moshi忽略字段)的答案,它表明使用关键字transient如下
private transient String your_variable_name;
Run Code Online (Sandbox Code Playgroud)
但我找不到在Kotlin完成这项工作的正确方法.
我正在寻找最有效的方式来转换String之类的
"[1,2,3,4,5]"
Run Code Online (Sandbox Code Playgroud)
到[1,2,3,4,5]Kotlin 的Int数组
我有这本字典:
d = {'val_1': [1,2,3,4,5], 'val_2': 4}
Run Code Online (Sandbox Code Playgroud)
我想从这里创建一个只有一行的pandas DataFrame.
当我做:
import pandas as pd
df = pd.DataFrame(d)
print(df)
Run Code Online (Sandbox Code Playgroud)
我得到5行:
val_1 val_2
0 1 4
1 2 4
2 3 4
3 4 4
4 5 4
Run Code Online (Sandbox Code Playgroud)
但是,当我将它附加到现有数据帧时,我得到了我想要的行为.
import pandas as pd
df = pd.DataFrame(d)
df = df.append(d, ignore_index=True)
print(df)
val_1 val_2
0 1 4
1 2 4
2 3 4
3 4 4
4 5 4
5 [1, 2, 3, 4, 5] 4
Run Code Online (Sandbox Code Playgroud)
如何从dict创建数据框,并在附加案例中只获得一行?
val_1 val_2
0 [1, 2, 3, …Run Code Online (Sandbox Code Playgroud) 我想知道在 Watson Studio 中使用 Jupyter Notebok 时如何将 Pandas 数据帧下载为 CSV 文件。