Telegram Group & Telegram Channel
Работаем с данными

pandas - это мощный инструмент для анализа данных в Python. С помощью данного фреймворка, работа с «реляционными» или «помеченными» данными простой и интуитивно понятной. Сегодня мы применим его для модификации csv файла.

Чтобы загрузить датафрейм из файла (пример), используем метод pd.read_csv().

Применим фильтр по полю sepal.length > 5. В SQL данная операция выглядела бы таким образом:
SELECT * FROM df WHERE sepal.length > 5.
В pandas же для получения необходимых строк фрейма можем использовать метод loc, передав в нее необходимый фильтр:
df = df.loc[df['sepal.length'] > 5]

Для удаления одной или нескольких колонок можно использовать метод df.drop():
df = df.drop(columns=['petal.width', 'petal.length'])

При сохранении в файл мы можем дополнительно указать pandas не добавлять генерирующийся индекс строкам, если он нам не нужен:
df.to_csv('new_iris.csv', index = False)

#pandas



tg-me.com/python_academy/744
Create:
Last Update:

Работаем с данными

pandas - это мощный инструмент для анализа данных в Python. С помощью данного фреймворка, работа с «реляционными» или «помеченными» данными простой и интуитивно понятной. Сегодня мы применим его для модификации csv файла.

Чтобы загрузить датафрейм из файла (пример), используем метод pd.read_csv().

Применим фильтр по полю sepal.length > 5. В SQL данная операция выглядела бы таким образом:
SELECT * FROM df WHERE sepal.length > 5.
В pandas же для получения необходимых строк фрейма можем использовать метод loc, передав в нее необходимый фильтр:
df = df.loc[df['sepal.length'] > 5]

Для удаления одной или нескольких колонок можно использовать метод df.drop():
df = df.drop(columns=['petal.width', 'petal.length'])

При сохранении в файл мы можем дополнительно указать pandas не добавлять генерирующийся индекс строкам, если он нам не нужен:
df.to_csv('new_iris.csv', index = False)

#pandas

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/744

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

What is Telegram Possible Future Strategies?

Cryptoassets enthusiasts use this application for their trade activities, and they may make donations for this cause.If somehow Telegram do run out of money to sustain themselves they will probably introduce some features that will not hinder the rudimentary principle of Telegram but provide users with enhanced and enriched experience. This could be similar to features where characters can be customized in a game which directly do not affect the in-game strategies but add to the experience.

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Python Academy from ye


Telegram Python Academy
FROM USA