How to select specific date format in column

lucky

I have this data set which have 3 rows. 2nd column is date column which have date in two different format. How can i select date of particular format to display that particular row. i mean there are more rows which have different date format. how can i select all the rows with date format year/date/month and then after selecting all these rows of this format year/date/month and then change to that year/month/date format . Main problem in selecting of particular format

     Country      date
18  Australia   2020-01-18  0.0   0.0   0.0   0.0   44648.71    25499881.0  2020-03-24
19  Australia   2020-19-01  0.0   0.0   0.0   0.0   44648.71    25499881.0  2020-03-24
20  Australia   2020-01-20  0.0   0.0   0.0   0.0   44648.71    25499881.0  2020-03-24
SKM

You can try this option (not very elegant):

Dataset:

Country,date
Australia,2020-01-18
Australia,2020-19-01
Australia,2020-01-20

Code:

import pandas as pd
import numpy as np
df = pd.read_csv("file.csv")
df = df.astype('str')
df['date'] = np.where(df['date'].str[5:7].astype('int') > 12
                    , df['date'].str[0:4] + df['date'].str[7:11] + df['date'].str[4:7]
                    , df['date'])

print(df)

Output:

     Country        date
0  Australia  2020-01-18
1  Australia  2020-01-19
2  Australia  2020-01-20

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to format Vuetify data table date column?

分類Dev

How to convert this whole column into date format?

分類Dev

How to specify column format in SELECT INTO statements in SQL?

分類Dev

How to input a date with a specific date format in struts 2.2.3.1?

分類Dev

How to select a column containing a specific value

分類Dev

How to get Date according to my timezone with specific format

分類Dev

Format date string in a specific pattern

分類Dev

Parse Date and Time in specific format

分類Dev

How to check a date time column in a specific range in python panda?

分類Dev

MySQL date interval with specific date format

分類Dev

DynamoDB client select specific column

分類Dev

How to format a Date with Luxon?

分類Dev

How to format this date?

分類Dev

SELECT MAX()of Column、DATE Column and group by ID

分類Dev

How to select specific row column pairs in numpy array which have specific value?

分類Dev

Date conversion to specific format using Angular pipes

分類Dev

Using momentjs to format a date in a specific locale

分類Dev

Select all rows that dont match a date format?

分類Dev

Changing the date format of the column values in aSspark dataframe

分類Dev

Make date column into standard format using pandas

分類Dev

What is the Excel Date Format to retain dates in this specific format?

分類Dev

Format sql column when using select

分類Dev

How to extract "Date column" value for a specific file for Windows 7 x64, in C++

分類Dev

How to Define date format from a given date

分類Dev

How to replicate a 'new Date()' format?

分類Dev

How to convert date into given format?

分類Dev

How to change date format in JS

分類Dev

How to convert date format in JavaScript?

分類Dev

Laravel hasMany relationship select specific column issue

Related 関連記事

  1. 1

    How to format Vuetify data table date column?

  2. 2

    How to convert this whole column into date format?

  3. 3

    How to specify column format in SELECT INTO statements in SQL?

  4. 4

    How to input a date with a specific date format in struts 2.2.3.1?

  5. 5

    How to select a column containing a specific value

  6. 6

    How to get Date according to my timezone with specific format

  7. 7

    Format date string in a specific pattern

  8. 8

    Parse Date and Time in specific format

  9. 9

    How to check a date time column in a specific range in python panda?

  10. 10

    MySQL date interval with specific date format

  11. 11

    DynamoDB client select specific column

  12. 12

    How to format a Date with Luxon?

  13. 13

    How to format this date?

  14. 14

    SELECT MAX()of Column、DATE Column and group by ID

  15. 15

    How to select specific row column pairs in numpy array which have specific value?

  16. 16

    Date conversion to specific format using Angular pipes

  17. 17

    Using momentjs to format a date in a specific locale

  18. 18

    Select all rows that dont match a date format?

  19. 19

    Changing the date format of the column values in aSspark dataframe

  20. 20

    Make date column into standard format using pandas

  21. 21

    What is the Excel Date Format to retain dates in this specific format?

  22. 22

    Format sql column when using select

  23. 23

    How to extract "Date column" value for a specific file for Windows 7 x64, in C++

  24. 24

    How to Define date format from a given date

  25. 25

    How to replicate a 'new Date()' format?

  26. 26

    How to convert date into given format?

  27. 27

    How to change date format in JS

  28. 28

    How to convert date format in JavaScript?

  29. 29

    Laravel hasMany relationship select specific column issue

ホットタグ

アーカイブ