Home > OS >  DataFrame Manipulation using pyspark-pandas
DataFrame Manipulation using pyspark-pandas

Time:04-27

1998-02-10 1998-02-11 1998-02-12 1998-02-13 1998-02-14 1998-02-15 1998-02-16
    19        20         10          65         12         5          46
    10        17         15          45         10         20         45
    12        12         13          20         6          35         30

Desired Output: I want to skip every 2 cols in the dataframe and generate the below dataframe. Start from day 1 and after that skip every 2 days in between untill the end of dataframe.

1998-02-10  1998-02-13 1998-02-16
    19          65         46
    10          45         45
    12          20         30

CodePudding user response:

You can use .iloc with a slice:

df.iloc[:, ::3]

::3 specifies to select every 3rd column, starting with the first. It's identical to 0:0:3.

  • Related