我有一张这样的桌子:
Sub Button1_Click()
Dim inpts As Variant
Dim players() As Variant
With Worksheets("sheet3")
inpts = .Range("F2:F11").Value
ReDim players(1 To UBound(inpts, 1), 1 To 10)
Dim counts As Long
counts = 0
For counter = LBound(inpts) To UBound(inpts)
Dim arr() As String
arr = Split(inpts(counter, 1))
Dim element
For Each element In arr
If element = "PG" Or element = "SG" Or element = "SF" Or element = "PF" Or element = "C" Or element = "G" Or element = "F" Or element = "UTIL" Then
counts = counts + 1
Else
players(counter, counts) = players(counter, counts) & element & " "
End If
Next element
counts = 0
Next counter
.Range("L2").Resize(UBound(players, 1), UBound(players, 2)).Value = players
End With
End Sub
现在我想合并它们,只获取非NaN值为的列:
c0 | c1 | c2 | c3
________________________
1 | 2 |NaN | NaN
3 | 4 |NaN | NaN
NaN |NaN |5 | 6
NaN |NaN |28 | 3
Pandas有没有这样做的功能?
谢谢!
答案 0 :(得分:1)
使用apply
df.apply(lambda x : sorted(x,key=pd.isnull),1).dropna(1)
Out[458]:
c0 c1
0 1.0 2.0
1 3.0 4.0
2 5.0 6.0
3 28.0 3.0
答案 1 :(得分:1)
你可以使用combine_first()
public void Ld_IsSelectedChanged(object sender, EventArgs e)
{
//get the floating windows from the DockingManager
manager.FloatingWindows.ToList().ForEach(floatingWindow =>
{
floatingWindow.Owner = null;
floatingWindow.ShowInTaskbar = true;
var fw = floatingWindow.Model as LayoutDocumentFloatingWindow;
floatingWindow.Title = fw?.RootDocument?.Title ?? "";
});
}